#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 *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
int main(int argc, char *argv[], char *envp[]) {
  char username[256];
  int i = 0;
  while (envp[i] != NULL) {
    if (strstr(envp[i], "USER=") && envp[i][4] == '=') {
      char *a = strchr(envp[i], '=');
      strcpy(username, (a + (sizeof(char))));
      break;
    }
    i++;
  }
  printf("Hello, %s!\n", username);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x124(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     120e <main+0xce>
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11fa <main+0xba>
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x4(%rax),%eax
cmp    $0x3d,%eax
jne    11fa <main+0xba>
mov    -0x18(%rbp),%rax
movslq -0x124(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x130(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
jmp    120e <main+0xce>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1167 <main+0x27>
lea    -0x120(%rbp),%rsi
lea    0xdea(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    (%rdx),%rdi
test   %rdi,%rdi
je     11a9 <main+0x69>
mov    %rdx,%rbx
add    $0x8,%rbx
lea    0xea0(%rip),%r14
jmp    117c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     11a9 <main+0x69>
mov    %r14,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    -0x8(%rbx),%rdi
cmpb   $0x3d,0x4(%rdi)
jne    1170 <main+0x30>
mov    $0x3d,%esi
call   1040 <strchr@plt>
lea    0x1(%rax),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xe56(%rip),%rdi
mov    %rsp,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"USER=\00"
@.str.1 = [12 x i8] c"Hello, %s!\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [256 x i8]
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 0, i32* %9
br label %11
11: ; preds = %47, %3
%12 = load i8**, i8*** %7
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %50
18: ; preds = %11
%19 = load i8**, i8*** %7
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %47
26: ; preds = %18
%27 = load i8**, i8*** %7
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 61
br i1 %35, label %36, label %47
36: ; preds = %26
%37 = load i8**, i8*** %7
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i8* @strchr(i8* %41, i8 signext 61)
store i8* %42, i8** %10
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%44 = load i8*, i8** %10
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = call i32 @strcpy(i8* %43, i8* %45)
br label %50
47: ; preds = %26, %18
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %11
50: ; preds = %36, %11
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %51)
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@.str = [6 x i8] c"USER=\00"
@.str.1 = [12 x i8] c"Hello, %s!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %28, label %8
8: ; preds = %3, %23
%9 = phi i64 [ %24, %23 ], [ 0, %3 ]
%10 = phi i8* [ %26, %23 ], [ %6, %3 ]
%11 = phi i8** [ %25, %23 ], [ %2, %3 ]
%12 = tail call i64 @strstr(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %8
%15 = load i8*, i8** %11
%16 = getelementptr inbounds i8, i8* %15, i64 4
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 61
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i8* @strchr(i8* dereferenceable(1) %15, i8 signext 61)
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i32 @strcpy(i8* %5, i8* %21)
br label %28
23: ; preds = %14, %8
%24 = add nuw i64 %9, 1
%25 = getelementptr inbounds i8*, i8** %2, i64 %24
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %8
28: ; preds = %23, %3, %19
%29 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret i32 0
}