#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*/ RB_POWER_OFF;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ reboot(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i;
  puts("args:");
  for (i = 0; i < argc; ++i)
    puts(argv[i]);
  puts("");
  puts("env:");
  extern char **environ;
  char **env = environ;
  while (*env) {
    printf("%s\n", *env);
    env++;
  }
  puts("");
  reboot(RB_POWER_OFF);
}


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)
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1184 <main+0x54>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <puts@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <main+0x29>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11dc <main+0xac>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <main+0x7a>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1050 <reboot@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    1172 <main+0x32>
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
call   1040 <puts@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%rbp
mov    0x0(%rbp),%rsi
test   %rsi,%rsi
je     11c5 <main+0x85>
add    $0x8,%rbp
lea    0xe65(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    0x0(%rbp),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1060 <reboot@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"args:\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"env:\00"
@environ = external global i8**
@.str.3 = [4 x i8] c"%s\0A\00"
@RB_POWER_OFF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @puts(i8* %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %9
23: ; preds = %9
%24 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8**, i8*** @environ
store i8** %26, i8*** %7
br label %27
27: ; preds = %31, %23
%28 = load i8**, i8*** %7
%29 = load i8*, i8** %28
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i8**, i8*** %7
%33 = load i8*, i8** %32
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = load i8**, i8*** %7
%36 = getelementptr inbounds i8*, i8** %35, i32 1
store i8** %36, i8*** %7
br label %27
37: ; preds = %27
%38 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @RB_POWER_OFF
%40 = call i32 @reboot(i32 %39)
%41 = load i32, i32* %3
ret i32 %41
}

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