#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(int);
int foo(int);
int target_function(int n) {
  int target_variable, irrelevant_variable, relevant_variable;
  if (n > 10) {
    for (int i = 0; i < n; ++i)
      target_variable = target_variable + foo(i);
  } else {
    target_variable = bar(n);
  }
  irrelevant_variable = 1000;
  relevant_variable = target_variable - 100;
  return target_variable;
}


x86 assembly (clang, -O0):
<target_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jle    1173 <target_function+0x53>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116e <target_function+0x4e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <foo@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <target_function+0x1c>
jmp    117e <target_function+0x5e>
mov    -0x4(%rbp),%edi
call   1030 <bar@plt>
mov    %eax,-0x8(%rbp)
movl   $0x3e8,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x64,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<target_function>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
cmp    $0xb,%edi
jl     1148 <target_function+0x28>
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %ebp,%edi
call   1040 <foo@plt>
add    %eax,%ebx
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1130 <target_function+0x10>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %r14d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <bar@plt>

LLVM IR (-O0):
define i32 @target_function(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 10
br i1 %8, label %9, label %23
9: ; preds = %1
store i32 0, i32* %6
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %6
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %6
%17 = call i32 @foo(i32 %16)
%18 = add nsw i32 %15, %17
store i32 %18, i32* %3
br label %19
19: ; preds = %14
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %10
22: ; preds = %10
br label %26
23: ; preds = %1
%24 = load i32, i32* %2
%25 = call i32 @bar(i32 %24)
store i32 %25, i32* %3
br label %26
26: ; preds = %23, %22
store i32 1000, i32* %4
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 100
store i32 %28, i32* %5
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @target_function(i32 %0) {
%2 = icmp sgt i32 %0, 10
br i1 %2, label %3, label %10
3: ; preds = %1, %3
%4 = phi i32 [ %8, %3 ], [ 0, %1 ]
%5 = phi i32 [ %7, %3 ], [ undef, %1 ]
%6 = tail call i32 @foo(i32 %4)
%7 = add nsw i32 %6, %5
%8 = add nuw nsw i32 %4, 1
%9 = icmp eq i32 %8, %0
br i1 %9, label %12, label %3
10: ; preds = %1
%11 = tail call i32 @bar(i32 %0)
br label %12
12: ; preds = %3, %10
%13 = phi i32 [ %11, %10 ], [ %7, %3 ]
ret i32 %13
}