#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 pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int i, j = 1, m = 1, distant = 0, possible, n = 1, contnum = 0, numofrow,
         numofnum = 1, numofcol, number, ans[100], answer, startnum = 1, k;
  printf("We will calculate which number your choose\n");
  printf("Enter number of row: ");
  scanf("%d", &number);
  numofrow = number;
  numofcol = pow(2, numofrow - 1);
  possible = pow(2, numofrow) - 1;
  printf("You can pick from 1 to %d\n", possible);
  printf("If you see your number, enter 1 else 0\n");
  printf("===========================\n");
  for (i = 1; i <= numofrow; i++) {
    n = pow(2, i - 1);
    m = n;
    j = 1;
    for (; j <= numofcol;) {
      for (k = 1; k <= n; k++) {
        printf("%d ", m);
        m++;
        j++;
      }
      m = m + n;
    }
    scanf("%d", &ans[i]);
    printf("\n");
    answer += n * ans[i];
  }
  printf("Your number is %d", answer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x1c8(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     12e6 <main+0x1b6>
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     1291 <main+0x161>
movl   $0x1,-0x1cc(%rbp)
mov    -0x1cc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1283 <main+0x153>
mov    -0xc(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x1cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1cc(%rbp)
jmp    123d <main+0x10d>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1227 <main+0xf7>
movslq -0x4(%rbp),%rax
lea    -0x1c0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe0b(%rip),%rdi
call   1040 <scanf@plt>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
movslq -0x4(%rbp),%rcx
imul   -0x1c0(%rbp,%rcx,4),%eax
ff
add    -0x1c4(%rbp),%eax
mov    %eax,-0x1c4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <main+0xcb>
mov    -0x1c4(%rbp),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0xedf(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    -0x1(%rbx),%esi
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %eax,%r13d
mov    $0x2,%edi
mov    %ebx,%esi
call   1070 <pow@plt>
lea    -0x1(%rax),%esi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xec9(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
mov    %rbx,0x10(%rsp)
mov    $0x1,%ebp
lea    0xe47(%rip),%rbx
jmp    122c <main+0xdc>
nopl   0x0(%rax)
mov    0x18(%rsp),%rbp
lea    (%rsp,%rbp,4),%rsi
add    $0x20,%rsi
lea    0xe40(%rip),%rdi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x20(%rsp,%rbp,4),%eax
imul   %r15d,%eax
mov    0x8(%rsp),%esi
add    %eax,%esi
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     128a <main+0x13a>
mov    %esi,0x8(%rsp)
mov    %rbp,0x18(%rsp)
lea    -0x1(%rbp),%esi
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %eax,%r15d
test   %r13d,%r13d
jle    11f0 <main+0xa0>
mov    $0x1,%r12d
mov    %r15d,%ebp
jmp    1268 <main+0x118>
cs nopw 0x0(%rax,%rax,1)
nop
add    %r15d,%ebp
cmp    %r13d,%r12d
jg     11f0 <main+0xa0>
test   %r15d,%r15d
jle    1260 <main+0x110>
mov    %r15d,%r14d
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
add    $0xffffffff,%r14d
jne    1270 <main+0x120>
add    %r15d,%r12d
jmp    1260 <main+0x110>
lea    0xda4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"We will calculate which number your choose\0A\00"
@.str.1 = [22 x i8] c"Enter number of row: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"You can pick from 1 to %d\0A\00"
@.str.4 = [40 x i8] c"If you see your number, enter 1 else 0\0A\00"
@.str.5 = [29 x i8] c"===========================\0A\00"
@.str.6 = [4 x i8] c"%d \00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [18 x i8] c"Your number is %d\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [100 x i32]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 1, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
store i32 1, i32* %6
store i32 0, i32* %7
store i32 1, i32* %9
store i32 1, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%19 = load i32, i32* %11
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = sub nsw i32 %20, 1
%22 = call i32 @pow(i32 2, i32 %21)
store i32 %22, i32* %10
%23 = load i32, i32* %8
%24 = call i32 @pow(i32 2, i32 %23)
%25 = sub nsw i32 %24, 1
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %30
30: ; preds = %76, %0
%31 = load i32, i32* %1
%32 = load i32, i32* %8
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %79
34: ; preds = %30
%35 = load i32, i32* %1
%36 = sub nsw i32 %35, 1
%37 = call i32 @pow(i32 2, i32 %36)
store i32 %37, i32* %6
%38 = load i32, i32* %6
store i32 %38, i32* %3
store i32 1, i32* %2
br label %39
39: ; preds = %58, %34
%40 = load i32, i32* %2
%41 = load i32, i32* %10
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %62
43: ; preds = %39
store i32 1, i32* %15
br label %44
44: ; preds = %55, %43
%45 = load i32, i32* %15
%46 = load i32, i32* %6
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %58
48: ; preds = %44
%49 = load i32, i32* %3
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
br label %55
55: ; preds = %48
%56 = load i32, i32* %15
%57 = add nsw i32 %56, 1
store i32 %57, i32* %15
br label %44
58: ; preds = %44
%59 = load i32, i32* %3
%60 = load i32, i32* %6
%61 = add nsw i32 %59, %60
store i32 %61, i32* %3
br label %39
62: ; preds = %39
%63 = load i32, i32* %1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %64
%66 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%68 = load i32, i32* %6
%69 = load i32, i32* %1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [100 x i32], [100 x i32]* %12, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = mul nsw i32 %68, %72
%74 = load i32, i32* %13
%75 = add nsw i32 %74, %73
store i32 %75, i32* %13
br label %76
76: ; preds = %62
%77 = load i32, i32* %1
%78 = add nsw i32 %77, 1
store i32 %78, i32* %1
br label %30
79: ; preds = %30
%80 = load i32, i32* %13
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %80)
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Enter number of row: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"You can pick from 1 to %d\0A\00"
@.str.6 = [4 x i8] c"%d \00"
@.str.8 = [18 x i8] c"Your number is %d\00"
@str = [43 x i8] c"We will calculate which number your choose\00"
@str.9 = [39 x i8] c"If you see your number, enter 1 else 0\00"
@str.10 = [28 x i8] c"===========================\00"
define void @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
%10 = call i32 @pow(i32 2, i32 %9)
%11 = call i32 @pow(i32 2, i32 %8)
%12 = add nsw i32 %11, -1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.9, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
%16 = icmp sgt i32 %8, 0
%17 = icmp slt i32 %10, 1
%18 = add nuw i32 %8, 1
%19 = zext i32 %18 to i64
br label %20
20: ; preds = %0, %45
%21 = phi i64 [ 1, %0 ], [ %52, %45 ]
%22 = phi i32 [ undef, %0 ], [ %51, %45 ]
%23 = trunc i64 %21 to i32
%24 = add i32 %23, -1
%25 = call i32 @pow(i32 2, i32 %24)
br i1 %17, label %45, label %26
26: ; preds = %20
%27 = icmp slt i32 %25, 1
br label %28
28: ; preds = %26, %40
%29 = phi i32 [ 1, %26 ], [ %42, %40 ]
%30 = phi i32 [ %25, %26 ], [ %43, %40 ]
br i1 %27, label %40, label %31
31: ; preds = %28, %31
%32 = phi i32 [ %36, %31 ], [ 1, %28 ]
%33 = phi i32 [ %35, %31 ], [ %30, %28 ]
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = add nsw i32 %33, 1
%36 = add nuw i32 %32, 1
%37 = icmp eq i32 %32, %25
br i1 %37, label %38, label %31
38: ; preds = %31
%39 = add i32 %25, %29
br label %40
40: ; preds = %38, %28
%41 = phi i32 [ %30, %28 ], [ %35, %38 ]
%42 = phi i32 [ %29, %28 ], [ %39, %38 ]
%43 = add nsw i32 %41, %25
%44 = icmp sgt i32 %42, %10
br i1 %44, label %45, label %28
45: ; preds = %40, %20
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %21
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %46)
%48 = call i32 @putchar(i32 10)
%49 = load i32, i32* %46
%50 = mul nsw i32 %49, %25
%51 = add nsw i32 %50, %22
%52 = add nuw nsw i64 %21, 1
%53 = icmp eq i64 %52, %19
br i1 %53, label %54, label %20
54: ; preds = %45
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %51)
ret void
}