#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int bar_OK();
int cond_OK(int);
int foo_OK();
int main_bad() {
  int k1, k2, k3, k4;
  cond_OK(2);
  k1 = bar_OK() + foo_OK() + cond_OK(15) * 2;
  k2 = bar_OK() + foo_OK() + cond_OK(17) * 3;
  k3 = bar_OK() + foo_OK() + cond_OK(11) * 3;
  k4 = bar_OK() + foo_OK() + cond_OK(19) * 3;
  return 0;
}


x86 assembly (clang, -O0):
<main_bad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x2,%edi
call   1050 <cond_OK@plt>
mov    $0x0,%al
call   1040 <bar_OK@plt>
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <foo_OK@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    $0xf,%edi
call   1050 <cond_OK@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <bar_OK@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <foo_OK@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    $0x11,%edi
call   1050 <cond_OK@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
imul   $0x3,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <bar_OK@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <foo_OK@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    $0xb,%edi
call   1050 <cond_OK@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   $0x3,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <bar_OK@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <foo_OK@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    $0x13,%edi
call   1050 <cond_OK@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   $0x3,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_bad>:
push   %rax
mov    $0x2,%edi
call   1050 <cond_OK@plt>
xor    %eax,%eax
call   1040 <bar_OK@plt>
xor    %eax,%eax
call   1030 <foo_OK@plt>
mov    $0xf,%edi
call   1050 <cond_OK@plt>
xor    %eax,%eax
call   1040 <bar_OK@plt>
xor    %eax,%eax
call   1030 <foo_OK@plt>
mov    $0x11,%edi
call   1050 <cond_OK@plt>
xor    %eax,%eax
call   1040 <bar_OK@plt>
xor    %eax,%eax
call   1030 <foo_OK@plt>
mov    $0xb,%edi
call   1050 <cond_OK@plt>
xor    %eax,%eax
call   1040 <bar_OK@plt>
xor    %eax,%eax
call   1030 <foo_OK@plt>
mov    $0x13,%edi
call   1050 <cond_OK@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main_bad() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 @cond_OK(i32 2)
%6 = call i32 (...) @bar_OK()
%7 = call i32 (...) @foo_OK()
%8 = add nsw i32 %6, %7
%9 = call i32 @cond_OK(i32 15)
%10 = mul nsw i32 %9, 2
%11 = add nsw i32 %8, %10
store i32 %11, i32* %1
%12 = call i32 (...) @bar_OK()
%13 = call i32 (...) @foo_OK()
%14 = add nsw i32 %12, %13
%15 = call i32 @cond_OK(i32 17)
%16 = mul nsw i32 %15, 3
%17 = add nsw i32 %14, %16
store i32 %17, i32* %2
%18 = call i32 (...) @bar_OK()
%19 = call i32 (...) @foo_OK()
%20 = add nsw i32 %18, %19
%21 = call i32 @cond_OK(i32 11)
%22 = mul nsw i32 %21, 3
%23 = add nsw i32 %20, %22
store i32 %23, i32* %3
%24 = call i32 (...) @bar_OK()
%25 = call i32 (...) @foo_OK()
%26 = add nsw i32 %24, %25
%27 = call i32 @cond_OK(i32 19)
%28 = mul nsw i32 %27, 3
%29 = add nsw i32 %26, %28
store i32 %29, i32* %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main_bad() {
%1 = tail call i32 @cond_OK(i32 2)
%2 = tail call i32 (...) @bar_OK()
%3 = tail call i32 (...) @foo_OK()
%4 = tail call i32 @cond_OK(i32 15)
%5 = tail call i32 (...) @bar_OK()
%6 = tail call i32 (...) @foo_OK()
%7 = tail call i32 @cond_OK(i32 17)
%8 = tail call i32 (...) @bar_OK()
%9 = tail call i32 (...) @foo_OK()
%10 = tail call i32 @cond_OK(i32 11)
%11 = tail call i32 (...) @bar_OK()
%12 = tail call i32 (...) @foo_OK()
%13 = tail call i32 @cond_OK(i32 19)
ret i32 0
}