#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*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int snprintf(char *, int, char *, int, ...);
int main() {
  char buffer[100];
  int cx;
  cx = snprintf(buffer, 100, "The half of %d is %d", 60, 60 / 2);
  if (cx >= 0 && cx < 100) {
    snprintf(buffer + cx, 100 - cx, ", and the half of that is %d.",
             60 / 2 / 2);
    printf("%s\n", buffer + cx);
  }
  puts(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
lea    0xeae(%rip),%rdx
mov    $0x3c,%ecx
mov    $0x1e,%r8d
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     11b8 <main+0x88>
cmpl   $0x64,-0x74(%rbp)
jge    11b8 <main+0x88>
lea    -0x70(%rbp),%rdi
movslq -0x74(%rbp),%rax
add    %rax,%rdi
mov    $0x64,%esi
sub    -0x74(%rbp),%esi
lea    0xe80(%rip),%rdx
mov    $0xf,%ecx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x70(%rbp),%rsi
movslq -0x74(%rbp),%rax
add    %rax,%rsi
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xec2(%rip),%rdx
mov    %rsp,%rdi
mov    $0x64,%ebx
mov    $0x64,%esi
mov    $0x3c,%ecx
mov    $0x1e,%r8d
xor    %eax,%eax
call   1050 <snprintf@plt>
cmp    $0x63,%eax
ja     1191 <main+0x61>
mov    %eax,%ecx
lea    (%rsp,%rcx,1),%r14
sub    %eax,%ebx
lea    0xea4(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0xf,%ecx
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"The half of %d is %d\00"
@.str.1 = [30 x i8] c", and the half of that is %d.\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 60, i32 30)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i32, i32* %3
%17 = sub nsw i32 100, %16
%18 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %15, i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 15)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %11, %8, %0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%26 = call i32 @puts(i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"The half of %d is %d\00"
@.str.1 = [30 x i8] c", and the half of that is %d.\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 60, i32 30)
%4 = icmp ult i32 %3, 100
br i1 %4, label %5, label %11
5: ; preds = %0
%6 = zext i32 %3 to i64
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %6
%8 = sub nuw nsw i32 100, %3
%9 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %7, i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 15)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %11
11: ; preds = %5, %0
%12 = call i32 @puts(i8* %2)
ret i32 0
}