#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_MIN;
int INT_MIN;
int SHRT_MIN;
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_min_16() {
  char buf_int2str[34] = "";
  char buf_snprintf[34] = "";
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%x", CHAR_MIN);
  assert(!strcmp(int2str(CHAR_MIN, buf_int2str, 16), buf_snprintf));
  printf("min 16#%d:%s:%s\n", CHAR_MIN, buf_int2str, buf_snprintf);
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%x", SHRT_MIN);
  assert(!strcmp(int2str(SHRT_MIN, buf_int2str, 16), buf_snprintf));
  printf("min 16#%d:%s:%s\n", SHRT_MIN, buf_int2str, buf_snprintf);
  snprintf(buf_snprintf, sizeof(buf_snprintf), "%x", INT_MIN);
  assert(!strcmp(int2str(INT_MIN, buf_int2str, 16), buf_snprintf));
  printf("min 16#%d:%s:%s\n", INT_MIN, buf_int2str, buf_snprintf);
}


x86 assembly (clang, -O0):
<tst_min_16>:
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    $0x10,%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    $0x10,%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    $0x10,%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_min_16>:
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    $0x10,%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    $0x10,%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    $0x10,%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"%x\00"
@CHAR_MIN = global i32 0
@.str.1 = [17 x i8] c"min 16#%d:%s:%s\0A\00"
@SHRT_MIN = global i32 0
@INT_MIN = global i32 0
define void @tst_min_16() {
%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_MIN
%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_MIN
%9 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%10 = call i32 @int2str(i32 %8, i8* %9, i32 16)
%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_MIN
%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_MIN
%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_MIN
%25 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%26 = call i32 @int2str(i32 %24, i8* %25, i32 16)
%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_MIN
%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_MIN
%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_MIN
%41 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%42 = call i32 @int2str(i32 %40, i8* %41, i32 16)
%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_MIN
%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"%x\00"
@CHAR_MIN = global i32 0
@.str.1 = [17 x i8] c"min 16#%d:%s:%s\0A\00"
@SHRT_MIN = global i32 0
@INT_MIN = global i32 0
define void @tst_min_16() {
%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_MIN
%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_MIN
%8 = call i32 @int2str(i32 %7, i8* %3, i32 16)
%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_MIN
%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_MIN
%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_MIN
%18 = call i32 @int2str(i32 %17, i8* %3, i32 16)
%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_MIN
%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_MIN
%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_MIN
%28 = call i32 @int2str(i32 %27, i8* %3, i32 16)
%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_MIN
%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
}