#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void firstClassProb() {
  int i = 0, in;
  printf("\nEnter a #: ");
  scanf("%d", &in);
  while (in != 1) {
    in = in >> 1;
    i++;
    printf("\ni=%d:   in>>1=%d", i, in);
  }
  printf("\n\nEnd: i=%d,    in=%d", i, in);
}


x86 assembly (clang, -O0):
<firstClassProb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
je     1182 <firstClassProb+0x62>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <firstClassProb+0x2d>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firstClassProb>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edx
cmp    $0x1,%edx
je     117e <firstClassProb+0x5e>
lea    0xeb8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
sar    %edx
mov    %edx,0x4(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
cmp    $0x1,%edx
jne    1160 <firstClassProb+0x40>
lea    0xe9a(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\0AEnter a #: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0Ai=%d: in>>1=%d\00"
@.str.3 = [22 x i8] c"\0A\0AEnd: i=%d, in=%d\00"
define void @firstClassProb() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i32, i32* %2
%10 = ashr i32 %9, 1
store i32 %10, i32* %2
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14)
br label %5
16: ; preds = %5
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\0AEnter a #: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0Ai=%d: in>>1=%d\00"
@.str.3 = [22 x i8] c"\0A\0AEnd: i=%d, in=%d\00"
define void @firstClassProb() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 1
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %13, %7 ], [ %5, %0 ]
%9 = phi i32 [ %11, %7 ], [ 0, %0 ]
%10 = ashr i32 %8, 1
store i32 %10, i32* %1
%11 = add nuw nsw i32 %9, 1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %10)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %7
15: ; preds = %7, %0
%16 = phi i32 [ 0, %0 ], [ %11, %7 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 1)
ret void
}