#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 int_pow(int, int);
scalar_t__ power_two(int, int *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int x = int_pow(2, 0);
  printf("x = %i\n", x);
  int pow;
  int y = x;
  int j = 0;
  for (j = 0; j < 31; j++) {
    printf("j = %i\n", j);
    x = int_pow(2, j) + 12;
    if (power_two(x, &pow)) {
      y = pow + 1;
    } else {
      y = pow;
    }
    printf("power = %i\n", y);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <int_pow@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1f,-0x20(%rbp)
jge    11eb <main+0xbb>
mov    -0x20(%rbp),%esi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
mov    $0x2,%edi
call   1040 <int_pow@plt>
add    $0xc,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1030 <power_two@plt>
cmp    $0x0,%rax
je     11c8 <main+0x98>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ce <main+0x9e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1178 <main+0x48>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <int_pow@plt>
lea    0xeb3(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
lea    0xead(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xea9(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <int_pow@plt>
lea    0xc(%rax),%edi
mov    %r15,%rsi
call   1030 <power_two@plt>
mov    0x4(%rsp),%esi
cmp    $0x1,%rax
sbb    $0xffffffff,%esi
mov    %r12,%rdi
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    $0x1f,%ebx
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"x = %i\0A\00"
@.str.1 = [8 x i8] c"j = %i\0A\00"
@.str.2 = [12 x i8] c"power = %i\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @int_pow(i32 2, i32 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %18, %7 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @int_pow(i32 2, i32 %8)
%11 = add nsw i32 %10, 12
%12 = call i64 @power_two(i32 %11, i32* %3)
%13 = icmp ne i64 %12, 0
%14 = load i32, i32* %3
%15 = zext i1 %13 to i32
%16 = add nsw i32 %14, %15
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %8, 1
%19 = icmp eq i32 %18, 31
br i1 %19, label %20, label %7
20: ; preds = %7
ret i32 0
}