#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 getBit(int, int);
int /*<<< orphan*/ int2str(int, int, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int dec = 23;
  int base = 5;
  char str[7] = "   ";
  int2str(dec, base, str);
  printf("the int %d was converted to str %s (base %d)\n", dec, str, base);
  int hex = 0x8;
  int i = 3;
  int banged = getBit(hex, i);
  printf("the %dth bit of %d is %d\n", i, hex, banged);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x17,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
mov    0xead(%rip),%eax
mov    %eax,-0x13(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0xf(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x13(%rbp),%rdx
call   1030 <int2str@plt>
mov    -0x8(%rbp),%esi
lea    -0x13(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x8,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <getBit@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xb(%rsp)
movl   $0x202020,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    $0x17,%edi
mov    $0x5,%esi
mov    %rbx,%rdx
call   1030 <int2str@plt>
lea    0xea4(%rip),%rdi
mov    $0x17,%esi
mov    %rbx,%rdx
mov    $0x5,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x8,%edi
mov    $0x3,%esi
call   1050 <getBit@plt>
lea    0xea8(%rip),%rdi
mov    $0x3,%esi
mov    $0x8,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [7 x i8] c" \00\00\00\00"
@.str = [46 x i8] c"the int %d was converted to str %s (base %d)\0A\00"
@.str.1 = [26 x i8] c"the %dth bit of %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 23, i32* %2
store i32 5, i32* %3
%8 = bitcast [7 x i8]* %4 to i8*
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%12 = call i32 @int2str(i32 %9, i32 %10, i8* %11)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %14, i32 %15)
store i32 8, i32* %5
store i32 3, i32* %6
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @getBit(i32 %17, i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [7 x i8] c" \00\00\00\00"
@.str = [46 x i8] c"the int %d was converted to str %s (base %d)\0A\00"
@.str.1 = [26 x i8] c"the %dth bit of %d is %d\0A\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = call i32 @int2str(i32 23, i32 5, i8* %2)
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 23, i8* %2, i32 5)
%5 = call i32 @getBit(i32 8, i32 3)
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 8, i32 %5)
ret i32 0
}