#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*/ fromDecimal2(int, int, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char result[100];
  int n = 1087;
  int b = 16;
  int size = 0;
  result[size] = '\0';
  printf("%d at %d = \n", n, b);
  fromDecimal2(n, b, result, &size);
  result[size] = '\0';
  printf("%s\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x43f,-0x74(%rbp)
movl   $0x10,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movslq -0x7c(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%esi
mov    -0x78(%rbp),%edx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x74(%rbp),%edi
mov    -0x78(%rbp),%esi
lea    -0x70(%rbp),%rdx
lea    -0x7c(%rbp),%rcx
call   1040 <fromDecimal2@plt>
movslq -0x7c(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
movl   $0x0,0xc(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xeb4(%rip),%rdi
mov    $0x43f,%esi
mov    $0x10,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rcx
mov    $0x43f,%edi
mov    $0x10,%esi
mov    %rbx,%rdx
call   1050 <fromDecimal2@plt>
movslq 0xc(%rsp),%rax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d at %d = \0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1087, i32* %3
store i32 16, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %5
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %7
store i8 0, i8* %8
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @fromDecimal2(i32 %12, i32 %13, i8* %14, i32* %5)
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %17
store i8 0, i8* %18
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d at %d = \0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
store i8 0, i8* %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 1087, i32 16)
%6 = call i32 @fromDecimal2(i32 1087, i32 16, i8* %3, i32* %2)
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %8
store i8 0, i8* %9
%10 = call i32 @puts(i8* %3)
ret i32 0
}