#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int snprintf(char *, int, char *, unsigned int);
int main(void) {
  char buf[sizeof(3 + 1)];
  int value = 0x80000000;
  int result = snprintf(buf, sizeof(buf), "%u", value >> 24);
  printf("S: %d %#x\n", value, value);
  printf("S: %d %#x\n", result, result);
  printf("S: %s\n", buf);
  char buf2[sizeof(3 + 1)];
  unsigned int value2 = 0x80000000;
  int result2 = snprintf(buf2, sizeof(buf2), "%u", value2 >> 24);
  printf("U: %d %#x\n", value2, value2);
  printf("U: %d %#x\n", result2, result2);
  printf("U: %s\n", buf2);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x80000000,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
mov    $0x4,%esi
lea    0xeb4(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x80000000,-0x18(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x18(%rbp),%ecx
shr    $0x18,%ecx
mov    $0x4,%esi
lea    0xe55(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%r14
lea    0x4(%rsp),%r15
mov    %r15,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
mov    $0xffffff80,%ecx
call   1040 <snprintf@plt>
mov    %eax,%ebp
lea    0xeb2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x80000000,%esi
mov    $0x80000000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
mov    $0x80,%ecx
call   1040 <snprintf@plt>
mov    %eax,%ebp
lea    0xe70(%rip),%rbx
mov    %rbx,%rdi
mov    $0x80000000,%esi
mov    $0x80000000,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [11 x i8] c"S: %d %#x\0A\00"
@.str.2 = [7 x i8] c"S: %s\0A\00"
@.str.3 = [11 x i8] c"U: %d %#x\0A\00"
@.str.4 = [7 x i8] c"U: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 -2147483648, i32* %3
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %3
%10 = ashr i32 %9, 24
%11 = call i32 @snprintf(i8* %8, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %4
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 -2147483648, i32* %6
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%21 = load i32, i32* %6
%22 = lshr i32 %21, 24
%23 = call i32 @snprintf(i8* %20, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %7
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28)
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [11 x i8] c"S: %d %#x\0A\00"
@.str.2 = [7 x i8] c"S: %s\0A\00"
@.str.3 = [11 x i8] c"U: %d %#x\0A\00"
@.str.4 = [7 x i8] c"U: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [4 x i8]
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 -128)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 -2147483648, i32 -2147483648)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%9 = call i32 @snprintf(i8* %8, i32 4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 128)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 -2147483648, i32 -2147483648)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %9)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}