#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int cpow;
  int numaddr;
  int rcidr, cidr;
  if (argc != 2) {
    printf("Usage: %s <NumAddrs>\n", argv[0]);
    return 1;
  }
  numaddr = atoi(argv[1]);
  rcidr = 0;
  for (cpow = 1; cpow < numaddr; cpow <<= 1)
    rcidr++;
  cidr = 32 - rcidr;
  printf("%d\n", cidr);
  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)
cmpl   $0x2,-0x8(%rbp)
je     1161 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a2 <main+0x82>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x5f>
mov    $0x20,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    116b <main+0x4b>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    $0x20,%esi
cmp    $0x2,%eax
jl     1159 <main+0x39>
mov    $0x1,%ecx
mov    $0x20,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ecx,%ecx
add    $0xffffffff,%esi
cmp    %eax,%ecx
jl     1150 <main+0x30>
lea    0xeb6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1181 <main+0x61>
mov    (%rsi),%rsi
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Usage: %s <NumAddrs>\0A\00"
@.str.1 = [4 x i8] c"%d\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 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %37
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
store i32 0, i32* %8
store i32 1, i32* %6
br label %22
22: ; preds = %29, %17
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %29
29: ; preds = %26
%30 = load i32, i32* %6
%31 = shl i32 %30, 1
store i32 %31, i32* %6
br label %22
32: ; preds = %22
%33 = load i32, i32* %8
%34 = sub nsw i32 32, %33
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
store i32 0, i32* %3
br label %37
37: ; preds = %32, %12
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [22 x i8] c"Usage: %s <NumAddrs>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %20
12: ; preds = %7, %12
%13 = phi i32 [ %15, %12 ], [ 0, %7 ]
%14 = phi i32 [ %16, %12 ], [ 1, %7 ]
%15 = add nuw nsw i32 %13, 1
%16 = shl i32 %14, 1
%17 = icmp slt i32 %16, %10
br i1 %17, label %12, label %18
18: ; preds = %12
%19 = sub nsw i32 31, %13
br label %20
20: ; preds = %18, %7
%21 = phi i32 [ 32, %7 ], [ %19, %18 ]
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %20, %4
%24 = phi i32 [ 1, %4 ], [ 0, %20 ]
ret i32 %24
}