#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*/ buf_snprintf;

/* Variables and functions */
int CHAR_MAX;
int INT_MAX;
int SHRT_MAX;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ int2str(int, char *, int);
int /*<<< orphan*/ printf(char *, int, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
void tst_max_10() {
  char buf_int2str[34] = "";
  char buf_snprintf[34] = "";
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%d", CHAR_MAX);
  assert(!strcmp(int2str(CHAR_MAX, buf_int2str, 10), buf_snprintf));
  printf("max 10#%d:%s:%s\n", CHAR_MAX, buf_int2str, buf_snprintf);
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%d", SHRT_MAX);
  assert(!strcmp(int2str(SHRT_MAX, buf_int2str, 10), buf_snprintf));
  printf("max 10#%d:%s:%s\n", SHRT_MAX, buf_int2str, buf_snprintf);
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%d", INT_MAX);
  assert(!strcmp(int2str(INT_MAX, buf_int2str, 10), buf_snprintf));
  printf("max 10#%d:%s:%s\n", INT_MAX, buf_int2str, buf_snprintf);
}


x86 assembly (clang, -O0):
<tst_max_10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x22,%edx
call   1060 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x22,%edx
call   1060 <memset@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e55(%rip),%rax
mov    (%rax),%ecx
mov    $0x22,%esi
lea    0xe5f(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
lea    -0x60(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2dce(%rip),%rax
mov    (%rax),%ecx
mov    $0x22,%esi
lea    0xdf0(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
lea    -0x60(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xda2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2d6f(%rip),%rax
mov    (%rax),%ecx
mov    $0x22,%esi
lea    0xd81(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
lea    -0x60(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xd33(%rip),%rdi
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tst_max_10>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x60,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movw   $0x0,0x50(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movw   $0x0,0x20(%rsp)
mov    0x2e60(%rip),%r12
mov    (%r12),%ecx
lea    0xe6d(%rip),%r15
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x22,%esi
mov    %r15,%rdx
call   1050 <snprintf@plt>
mov    (%r12),%edi
lea    0x30(%rsp),%r14
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%esi
lea    0xe25(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
call   1040 <printf@plt>
mov    0x2ddd(%rip),%rbx
mov    (%rbx),%ecx
mov    %r13,%rdi
mov    $0x22,%esi
mov    %r15,%rdx
call   1050 <snprintf@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
call   1040 <printf@plt>
mov    0x2d9e(%rip),%rbx
mov    (%rbx),%ecx
mov    %r13,%rdi
mov    $0x22,%esi
mov    %r15,%rdx
call   1050 <snprintf@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <int2str@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@CHAR_MAX = global i32 0
@.str.1 = [17 x i8] c"max 10#%d:%s:%s\0A\00"
@SHRT_MAX = global i32 0
@INT_MAX = global i32 0
define void @tst_max_10() {
%1 = alloca [34 x i8]
%2 = alloca [34 x i8]
%3 = bitcast [34 x i8]* %1 to i8*
%4 = bitcast [34 x i8]* %2 to i8*
%5 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @CHAR_MAX
%7 = call i32 @snprintf(i8* %5, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @CHAR_MAX
%9 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%10 = call i32 @int2str(i32 %8, i8* %9, i32 10)
%11 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%12 = call i32 @strcmp(i32 %10, i8* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32, i32* @CHAR_MAX
%18 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%19 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %18, i8* %19)
%21 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%22 = load i32, i32* @SHRT_MAX
%23 = call i32 @snprintf(i8* %21, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @SHRT_MAX
%25 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%26 = call i32 @int2str(i32 %24, i8* %25, i32 10)
%27 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%28 = call i32 @strcmp(i32 %26, i8* %27)
%29 = icmp ne i32 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* @SHRT_MAX
%34 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%35 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %33, i8* %34, i8* %35)
%37 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%38 = load i32, i32* @INT_MAX
%39 = call i32 @snprintf(i8* %37, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = load i32, i32* @INT_MAX
%41 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%42 = call i32 @int2str(i32 %40, i8* %41, i32 10)
%43 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%44 = call i32 @strcmp(i32 %42, i8* %43)
%45 = icmp ne i32 %44, 0
%46 = xor i1 %45, true
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32, i32* @INT_MAX
%50 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%51 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %49, i8* %50, i8* %51)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@CHAR_MAX = global i32 0
@.str.1 = [17 x i8] c"max 10#%d:%s:%s\0A\00"
@SHRT_MAX = global i32 0
@INT_MAX = global i32 0
define void @tst_max_10() {
%1 = alloca [34 x i8]
%2 = alloca [34 x i8]
%3 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @CHAR_MAX
%6 = call i32 @snprintf(i8* %4, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @CHAR_MAX
%8 = call i32 @int2str(i32 %7, i8* %3, i32 10)
%9 = call i32 @strcmp(i32 %8, i8* %4)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* @CHAR_MAX
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %3, i8* %4)
%15 = load i32, i32* @SHRT_MAX
%16 = call i32 @snprintf(i8* %4, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @SHRT_MAX
%18 = call i32 @int2str(i32 %17, i8* %3, i32 10)
%19 = call i32 @strcmp(i32 %18, i8* %4)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* @SHRT_MAX
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %3, i8* %4)
%25 = load i32, i32* @INT_MAX
%26 = call i32 @snprintf(i8* %4, i32 34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @INT_MAX
%28 = call i32 @int2str(i32 %27, i8* %3, i32 10)
%29 = call i32 @strcmp(i32 %28, i8* %4)
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* @INT_MAX
%34 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %33, i8* %3, i8* %4)
ret void
}