#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int main(void) {
  struct {
    char buf[8];
    int var;
  } v = {"", 0x55555555};
  snprintf(v.buf, sizeof(v.buf), "%s%s", getenv("ASDF"), getenv("FRRR"));
  printf("char buf[8] = \"%s\"\n"
         "int var = 0x%.8x\n",
         v.buf, v.var);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xeaf(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    0xea4(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    %rax,%r8
mov    $0x8,%esi
lea    0xe7e(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xecb(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xeb8(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xebd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xeb3(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe9d(%rip),%rdx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rbx,%rcx
mov    %rax,%r8
call   1050 <snprintf@plt>
mov    0x10(%rsp),%edx
lea    0xe89(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.anon = type { [8 x i8], i32 }
@__const.main.v = %struct.anon { [8 x i8] zeroinitializer, i32 1431655765 }
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c"ASDF\00"
@.str.2 = [5 x i8] c"FRRR\00"
@.str.3 = [37 x i8] c"char buf[8] = \22%s\22\0Aint var = 0x%.8x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.anon
store i32 0, i32* %1
%3 = bitcast %struct.anon* %2 to i8*
%4 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 0
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @snprintf(i8* %5, i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 0
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%11 = getelementptr inbounds %struct.anon, %struct.anon* %2, i32 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %10, i32 %12)
ret i32 0
}

LLVM IR (-O2):
%struct.anon = type { [8 x i8], i32 }
@__const.main.v = %struct.anon { [8 x i8] zeroinitializer, i32 1431655765 }
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [5 x i8] c"ASDF\00"
@.str.2 = [5 x i8] c"FRRR\00"
@.str.3 = [37 x i8] c"char buf[8] = \22%s\22\0Aint var = 0x%.8x\0A\00"
define i32 @main() {
%1 = alloca %struct.anon
%2 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 0, i64 0
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @snprintf(i8* %2, i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = getelementptr inbounds %struct.anon, %struct.anon* %1, i64 0, i32 1
%7 = load i32, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %2, i32 %7)
ret i32 0
}