#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 foo(int);
scalar_t__ is_odd(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int n = 10, j = 3, a;
  for (int i = 0; i < n; i++) {
    j = foo(j);
    if (is_odd(j))
      a = j;
    else
      a = foo(j % 3);
  }
  printf("%d\n", a);
  return a;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b0 <main+0x80>
mov    -0xc(%rbp),%edi
call   1050 <foo@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <is_odd@plt>
cmp    $0x0,%rax
je     1188 <main+0x58>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    119d <main+0x6d>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <foo@plt>
mov    %eax,-0x10(%rbp)
jmp    11a2 <main+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
mov    -0x10(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x3,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    116c <main+0x3c>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    11a4 <main+0x74>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    11dc <main+0xac>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    1214 <main+0xe4>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    124c <main+0x11c>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    1284 <main+0x154>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    12bc <main+0x18c>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    12f4 <main+0x1c4>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    132c <main+0x1fc>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
mov    %ebx,%edi
sub    %eax,%edi
call   1050 <foo@plt>
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <is_odd@plt>
test   %rax,%rax
jne    1366 <main+0x236>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1050 <foo@plt>
mov    %eax,%ebx
lea    0xc93(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 3, i32* %3
store i32 0, i32* %5
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i32, i32* %3
%12 = call i32 @foo(i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i64 @is_odd(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i32, i32* %3
store i32 %17, i32* %4
br label %22
18: ; preds = %10
%19 = load i32, i32* %3
%20 = srem i32 %19, 3
%21 = call i32 @foo(i32 %20)
store i32 %21, i32* %4
br label %22
22: ; preds = %18, %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %6
26: ; preds = %6
%27 = load i32, i32* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @foo(i32 3)
%2 = tail call i64 @is_odd(i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = srem i32 %1, 3
%6 = tail call i32 @foo(i32 %5)
br label %7
7: ; preds = %0, %4
%8 = tail call i32 @foo(i32 %1)
%9 = tail call i64 @is_odd(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = srem i32 %8, 3
%13 = tail call i32 @foo(i32 %12)
br label %14
14: ; preds = %11, %7
%15 = tail call i32 @foo(i32 %8)
%16 = tail call i64 @is_odd(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = srem i32 %15, 3
%20 = tail call i32 @foo(i32 %19)
br label %21
21: ; preds = %18, %14
%22 = tail call i32 @foo(i32 %15)
%23 = tail call i64 @is_odd(i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = srem i32 %22, 3
%27 = tail call i32 @foo(i32 %26)
br label %28
28: ; preds = %25, %21
%29 = tail call i32 @foo(i32 %22)
%30 = tail call i64 @is_odd(i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = srem i32 %29, 3
%34 = tail call i32 @foo(i32 %33)
br label %35
35: ; preds = %32, %28
%36 = tail call i32 @foo(i32 %29)
%37 = tail call i64 @is_odd(i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = srem i32 %36, 3
%41 = tail call i32 @foo(i32 %40)
br label %42
42: ; preds = %39, %35
%43 = tail call i32 @foo(i32 %36)
%44 = tail call i64 @is_odd(i32 %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = srem i32 %43, 3
%48 = tail call i32 @foo(i32 %47)
br label %49
49: ; preds = %46, %42
%50 = tail call i32 @foo(i32 %43)
%51 = tail call i64 @is_odd(i32 %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = srem i32 %50, 3
%55 = tail call i32 @foo(i32 %54)
br label %56
56: ; preds = %53, %49
%57 = tail call i32 @foo(i32 %50)
%58 = tail call i64 @is_odd(i32 %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = srem i32 %57, 3
%62 = tail call i32 @foo(i32 %61)
br label %63
63: ; preds = %60, %56
%64 = tail call i32 @foo(i32 %57)
%65 = tail call i64 @is_odd(i32 %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = srem i32 %64, 3
%69 = tail call i32 @foo(i32 %68)
br label %70
70: ; preds = %67, %63
%71 = phi i32 [ %69, %67 ], [ %64, %63 ]
%72 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
ret i32 %71
}