#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 */
typedef int /*<<< orphan*/ buf2;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int UINT_MAX;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int uintoxa(char *, int, int);
int main(int argc, char *argv[]) {
  char buf[12];
  char buf2[3];
  if (uintoxa(buf, sizeof(buf), 15) == -1)
    return 1;
  if (strcmp(buf, "F") != 0) {
    printf("uintoxa: %s, should be %s\n", buf, "F");
    return 1;
  }
  if (uintoxa(buf, sizeof(buf), 1023) == -1)
    return 1;
  if (strcmp(buf, "3FF") != 0) {
    printf("uintoxa: %s, should be %s\n", buf, "3FF");
    return 1;
  }
  if (uintoxa(buf, sizeof(buf), 0) == -1)
    return 1;
  if (strcmp(buf, "0") != 0) {
    printf("uintoxa: %s, should be %s\n", buf, "0");
    return 1;
  }
  if (uintoxa(buf, sizeof(buf), UINT_MAX) == -1)
    return 1;
  if (strcmp(buf, "FFFFFFFF") != 0) {
    printf("uintoxa: %s, should be %s\n", buf, "FFFFFFFF");
    return 1;
  }
  if (uintoxa(buf2, sizeof(buf2), UINT_MAX) != -1)
    return 1;
  if (strlen(buf2) != 2) {
    printf("uintoxa: strlen failure\n");
    return 1;
  }
  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)
lea    -0x1c(%rbp),%rdi
mov    $0xc,%esi
mov    $0xf,%edx
call   1060 <uintoxa@plt>
cmp    $0xffffffff,%eax
jne    117e <main+0x3e>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11bd <main+0x7d>
lea    -0x1c(%rbp),%rsi
lea    0xe5d(%rip),%rdi
lea    0xe73(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
mov    $0xc,%esi
mov    $0x3ff,%edx
call   1060 <uintoxa@plt>
cmp    $0xffffffff,%eax
jne    11e5 <main+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1224 <main+0xe4>
lea    -0x1c(%rbp),%rsi
lea    0xdf6(%rip),%rdi
lea    0xe0a(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1060 <uintoxa@plt>
cmp    $0xffffffff,%eax
jne    1249 <main+0x109>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1288 <main+0x148>
lea    -0x1c(%rbp),%rsi
lea    0xd92(%rip),%rdi
lea    0xdaa(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
mov    0x2d55(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1060 <uintoxa@plt>
cmp    $0xffffffff,%eax
jne    12b4 <main+0x174>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1c(%rbp),%rdi
lea    0xd62(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12f3 <main+0x1b3>
lea    -0x1c(%rbp),%rsi
lea    0xd27(%rip),%rdi
lea    0xd41(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1f(%rbp),%rdi
mov    0x2cea(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1060 <uintoxa@plt>
cmp    $0xffffffff,%eax
je     131f <main+0x1df>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
lea    -0x1f(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
je     134b <main+0x20b>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1352 <main+0x212>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x9(%rsp),%rdi
mov    $0xc,%esi
mov    $0xf,%edx
call   1070 <uintoxa@plt>
mov    $0x1,%ebx
cmp    $0xffffffff,%eax
je     11aa <main+0x5a>
lea    0xea1(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b4 <main+0x64>
lea    0xe6e(%rip),%rdi
lea    0xe84(%rip),%rdx
lea    0x9(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0x9(%rsp),%rdi
mov    $0xc,%esi
mov    $0x3ff,%edx
call   1070 <uintoxa@plt>
cmp    $0xffffffff,%eax
je     11aa <main+0x5a>
lea    0xe47(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11f3 <main+0xa3>
lea    0xe16(%rip),%rdi
lea    0xe2a(%rip),%rdx
jmp    1199 <main+0x49>
lea    0x9(%rsp),%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1070 <uintoxa@plt>
cmp    $0xffffffff,%eax
je     11aa <main+0x5a>
lea    0xe0f(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1232 <main+0xe2>
lea    0xdda(%rip),%rdi
lea    0xdf2(%rip),%rdx
jmp    1199 <main+0x49>
mov    0x2daf(%rip),%r14
mov    (%r14),%edx
lea    0x9(%rsp),%rdi
mov    $0xc,%esi
call   1070 <uintoxa@plt>
cmp    $0xffffffff,%eax
je     11aa <main+0x5a>
lea    0xdc6(%rip),%rsi
lea    0x9(%rsp),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     127d <main+0x12d>
lea    0xd8f(%rip),%rdi
lea    0xda9(%rip),%rdx
jmp    1199 <main+0x49>
mov    (%r14),%edx
lea    0x15(%rsp),%rdi
mov    $0x3,%esi
call   1070 <uintoxa@plt>
cmp    $0xffffffff,%eax
jne    11aa <main+0x5a>
lea    0x15(%rsp),%rdi
call   1040 <strlen@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
je     11aa <main+0x5a>
lea    0xd76(%rip),%rdi
call   1030 <puts@plt>
jmp    11a5 <main+0x55>

LLVM IR (-O0):
@.str = [2 x i8] c"F\00"
@.str.1 = [27 x i8] c"uintoxa: %s, should be %s\0A\00"
@.str.2 = [4 x i8] c"3FF\00"
@.str.3 = [2 x i8] c"0\00"
@UINT_MAX = global i32 0
@.str.4 = [9 x i8] c"FFFFFFFF\00"
@.str.5 = [25 x i8] c"uintoxa: strlen failure\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [12 x i8]
%7 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%9 = call i32 @uintoxa(i8* %8, i32 12, i32 15)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %69
12: ; preds = %2
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %69
19: ; preds = %12
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%21 = call i32 @uintoxa(i8* %20, i32 12, i32 1023)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %3
br label %69
24: ; preds = %19
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %69
31: ; preds = %24
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%33 = call i32 @uintoxa(i8* %32, i32 12, i32 0)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %3
br label %69
36: ; preds = %31
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %69
43: ; preds = %36
%44 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%45 = load i32, i32* @UINT_MAX
%46 = call i32 @uintoxa(i8* %44, i32 12, i32 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %49
48: ; preds = %43
store i32 1, i32* %3
br label %69
49: ; preds = %43
%50 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %69
56: ; preds = %49
%57 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%58 = load i32, i32* @UINT_MAX
%59 = call i32 @uintoxa(i8* %57, i32 3, i32 %58)
%60 = icmp ne i32 %59, -1
br i1 %60, label %61, label %62
61: ; preds = %56
store i32 1, i32* %3
br label %69
62: ; preds = %56
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%64 = call i32 @strlen(i8* %63)
%65 = icmp ne i32 %64, 2
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %69
68: ; preds = %62
store i32 0, i32* %3
br label %69
69: ; preds = %68, %66, %61, %53, %48, %40, %35, %28, %23, %16, %11
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [2 x i8] c"F\00"
@.str.1 = [27 x i8] c"uintoxa: %s, should be %s\0A\00"
@.str.2 = [4 x i8] c"3FF\00"
@.str.3 = [2 x i8] c"0\00"
@UINT_MAX = global i32 0
@.str.4 = [9 x i8] c"FFFFFFFF\00"
@str = [24 x i8] c"uintoxa: strlen failure\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [12 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = call i32 @uintoxa(i8* %5, i32 12, i32 15)
%8 = icmp eq i32 %7, -1
br i1 %8, label %48, label %9
9: ; preds = %2
%10 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %48
14: ; preds = %9
%15 = call i32 @uintoxa(i8* %5, i32 12, i32 1023)
%16 = icmp eq i32 %15, -1
br i1 %16, label %48, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %48
22: ; preds = %17
%23 = call i32 @uintoxa(i8* %5, i32 12, i32 0)
%24 = icmp eq i32 %23, -1
br i1 %24, label %48, label %25
25: ; preds = %22
%26 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %48
30: ; preds = %25
%31 = load i32, i32* @UINT_MAX
%32 = call i32 @uintoxa(i8* %5, i32 12, i32 %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %48, label %34
34: ; preds = %30
%35 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %48
39: ; preds = %34
%40 = load i32, i32* @UINT_MAX
%41 = call i32 @uintoxa(i8* %6, i32 3, i32 %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = call i32 @strlen(i8* %6)
%45 = icmp eq i32 %44, 2
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %48
48: ; preds = %43, %39, %30, %22, %14, %2, %46, %37, %28, %20, %12
%49 = phi i32 [ 1, %12 ], [ 1, %20 ], [ 1, %28 ], [ 1, %37 ], [ 1, %46 ], [ 1, %2 ], [ 1, %14 ], [ 1, %22 ], [ 1, %30 ], [ 1, %39 ], [ 0, %43 ]
ret i32 %49
}