#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*/ __wrap_write(int, char *, int /*<<< orphan*/);
char *gcvt(double, int, char *);
scalar_t__ sprintf(char *, char *, double, char *);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  int ret = 42;
  char buf[1024];
  char buf2[1024];
  while (ret == 42) {
    ret += sprintf(buf, "hello world: %f %s\n", 1.0 / 3.0, gcvt(3.5, 10, buf2));
    __wrap_write(1, buf, strlen(buf));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
cmpl   $0x2a,-0x8(%rbp)
jne    11e7 <main+0xa7>
lea    -0x410(%rbp),%rax
mov    %rax,-0x820(%rbp)
lea    -0x810(%rbp),%rsi
movsd  0xe88(%rip),%xmm0
mov    $0xa,%edi
call   1040 <gcvt@plt>
mov    -0x820(%rbp),%rdi
mov    %rax,%rdx
lea    0xe75(%rip),%rsi
movsd  0xe5d(%rip),%xmm0
call   1050 <sprintf@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x818(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x818(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1060 <__wrap_write@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsp,%r14
lea    0xeb8(%rip),%r15
lea    0x400(%rsp),%r12
movsd  0xe98(%rip),%xmm0
mov    $0xa,%edi
mov    %r14,%rsi
call   1040 <gcvt@plt>
mov    %r12,%rdi
mov    %r15,%rsi
movsd  0xe85(%rip),%xmm0
mov    %rax,%rdx
call   1050 <sprintf@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1060 <__wrap_write@plt>
test   %ebx,%ebx
je     1160 <main+0x20>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"hello world: %f %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 42, i32* %2
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 42
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = call i8* @gcvt(double 3.500000e+00, i32 10, i8* %10)
%12 = call i64 @sprintf(i8* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double 0x3FD5555555555555, i8* %11)
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %2
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @__wrap_write(i32 1, i8* %17, i32 %19)
br label %5
21: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"hello world: %f %s\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = call i8* @gcvt(double 3.500000e+00, i32 10, i8* %4)
%7 = call i64 @sprintf(i8* %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double 0x3FD5555555555555, i8* %6)
%8 = trunc i64 %7 to i32
%9 = call i32 @strlen(i8* %3)
%10 = call i32 @__wrap_write(i32 1, i8* %3, i32 %9)
%11 = icmp eq i32 %8, 0
br i1 %11, label %5, label %12
12: ; preds = %5
ret i32 0
}