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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *);
void go(char *msg) {
  int i = 0;
  char tmpbuf[512];
  printf("i = %p\n", &i);
  snprintf(tmpbuf, sizeof(tmpbuf), "helloworld\n");
  tmpbuf[sizeof(tmpbuf) - 1] = '\0';
  printf("msg: %s, i = %d\n", tmpbuf, i);
}


x86 assembly (clang, -O0):
<go>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
lea    0xead(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x11(%rbp)
lea    -0x210(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<go>:
push   %rbx
sub    $0x210,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebe(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1040 <snprintf@plt>
movb   $0x0,0x20f(%rsp)
mov    0xc(%rsp),%edx
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x210,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"i = %p\0A\00"
@.str.1 = [12 x i8] c"helloworld\0A\00"
@.str.2 = [17 x i8] c"msg: %s, i = %d\0A\00"
define void @go(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [512 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 512, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 511
store i8 0, i8* %8
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %9, i32 %10)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"i = %p\0A\00"
@.str.1 = [12 x i8] c"helloworld\0A\00"
@.str.2 = [17 x i8] c"msg: %s, i = %d\0A\00"
define void @go(i8* nocapture readnone %0) {
%2 = alloca i32
%3 = alloca [512 x i8]
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = call i32 @snprintf(i8* %5, i32 512, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 511
store i8 0, i8* %8
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %9)
ret void
}