#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 ssize_t;

/* Variables and functions */
int write(int, char *, int);
int main(int argc, char *argv[], char *envp[]) {
  ssize_t res = write(1, "Hello, World!\n", sizeof("Hello, World!\n") - 1);
  ;
  write(1, "argv:\n", sizeof("argv:\n") - 1);
  ;
  for (int i = 1; i < argc; ++i) {
    write(1, argv[i], 1);
    write(1, "\n", sizeof("\n") - 1);
    ;
  }
  if (envp) {
    write(1, "envp:\n", sizeof("envp:\n") - 1);
    ;
    while (*envp) {
      write(1, *envp, 4);
      write(1, "\n", sizeof("\n") - 1);
      ;
      ++envp;
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%edi
lea    0xeca(%rip),%rsi
mov    $0xe,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1,%edi
lea    0xec0(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <main+0x95>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe7d(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1160 <main+0x50>
cmpq   $0x0,-0x18(%rbp)
je     1213 <main+0x103>
mov    $0x1,%edi
lea    0xe5a(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     120e <main+0xfe>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe17(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    11c6 <main+0xb6>
jmp    1213 <main+0x103>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%r15d
lea    0xed5(%rip),%rsi
mov    $0x1,%edi
mov    $0xe,%edx
call   1030 <write@plt>
mov    %eax,%r14d
lea    0xecb(%rip),%rsi
mov    $0x1,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x2,%r15d
jl     119e <main+0x8e>
mov    %r15d,%r13d
mov    $0x1,%ebp
lea    0xea5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <main+0x60>
test   %rbx,%rbx
je     11fd <main+0xed>
lea    0xe6c(%rip),%rsi
mov    $0x1,%edi
mov    $0x6,%edx
call   1030 <write@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11fd <main+0xed>
add    $0x8,%rbx
lea    0xe41(%rip),%rbp
nopl   0x0(%rax)
mov    $0x1,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11d0 <main+0xc0>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Hello, World!\0A\00"
@.str.1 = [7 x i8] c"argv:\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [7 x i8] c"envp:\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 i32
%9 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = call i32 @write(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
store i32 %10, i32* %8
%11 = call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
store i32 1, i32* %9
br label %12
12: ; preds = %24, %3
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i8**, i8*** %6
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @write(i32 1, i8* %21, i32 1)
%23 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %24
24: ; preds = %16
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %12
27: ; preds = %12
%28 = load i8**, i8*** %7
%29 = icmp ne i8** %28, null
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
br label %32
32: ; preds = %36, %30
%33 = load i8**, i8*** %7
%34 = load i8*, i8** %33
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i8**, i8*** %7
%38 = load i8*, i8** %37
%39 = call i32 @write(i32 1, i8* %38, i32 4)
%40 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%41 = load i8**, i8*** %7
%42 = getelementptr inbounds i8*, i8** %41, i32 1
store i8** %42, i8*** %7
br label %32
43: ; preds = %32
br label %44
44: ; preds = %43, %27
%45 = load i32, i32* %8
ret i32 %45
}

LLVM IR (-O2):
@.str = [15 x i8] c"Hello, World!\0A\00"
@.str.1 = [7 x i8] c"argv:\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [7 x i8] c"envp:\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** %2) {
%4 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 14)
%5 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %11, %3
%10 = icmp eq i8** %2, null
br i1 %10, label %31, label %19
11: ; preds = %7, %11
%12 = phi i64 [ 1, %7 ], [ %17, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @write(i32 1, i8* %14, i32 1)
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %9, label %11
19: ; preds = %9
%20 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%21 = load i8*, i8** %2
%22 = icmp eq i8* %21, null
br i1 %22, label %31, label %23
23: ; preds = %19, %23
%24 = phi i8* [ %29, %23 ], [ %21, %19 ]
%25 = phi i8** [ %28, %23 ], [ %2, %19 ]
%26 = tail call i32 @write(i32 1, i8* %24, i32 4)
%27 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%28 = getelementptr inbounds i8*, i8** %25, i64 1
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %23
31: ; preds = %23, %19, %9
ret i32 %4
}