main(argc, argv, envp) char **argv, **envp;
{
  register int rargc;
  rargc = argc;
  printf("main called with argc = %d\n", argc);
  printf("Arguments:\n");
  while (rargc--) {
    printf("	%s\n", *argv++);
  }
  printf("Environment:\n");
  while (*envp) {
    printf("	%s\n", *envp++);
  }
  return (argc - 1);
}


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    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1188 <main+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0x3f>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c9 <main+0xb9>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%rsi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1196 <main+0x86>
mov    -0x8(%rbp),%eax
sub    $0x1,%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,%r14d
lea    0xec5(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
je     1187 <main+0x67>
mov    %r14d,%r13d
lea    0xebc(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbp,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
jne    1170 <main+0x50>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11c6 <main+0xa6>
add    $0x8,%rbx
lea    0xe76(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11b0 <main+0x90>
add    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"main called with argc = %d\0A\00"
@.str.1 = [12 x i8] c"Arguments:\0A\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
@.str.3 = [14 x i8] c"Environment:\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
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i32, i32* %5
store i32 %9, i32* %8
%10 = load i32, i32* %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %17, %3
%14 = load i32, i32* %8
%15 = add nsw i32 %14, -1
store i32 %15, i32* %8
%16 = icmp ne i32 %14, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %6
%20 = load i8*, i8** %18
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %13
22: ; preds = %13
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %28, %22
%25 = load i8**, i8*** %7
%26 = load i8*, i8** %25
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8**, i8*** %7
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %7
%31 = load i8*, i8** %29
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %24
33: ; preds = %24
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
ret i32 %35
}

LLVM IR (-O2):
@.str = [28 x i8] c"main called with argc = %d\0A\00"
@.str.2 = [5 x i8] c"\09%s\0A\00"
@str = [11 x i8] c"Arguments:\00"
@str.4 = [13 x i8] c"Environment:\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%6 = icmp eq i32 %0, 0
br i1 %6, label %15, label %7
7: ; preds = %3, %7
%8 = phi i32 [ %10, %7 ], [ %0, %3 ]
%9 = phi i8** [ %11, %7 ], [ %1, %3 ]
%10 = add nsw i32 %8, -1
%11 = getelementptr inbounds i8*, i8** %9, i64 1
%12 = load i8*, i8** %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = icmp eq i32 %10, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %3
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%17 = load i8*, i8** %2
%18 = icmp eq i8* %17, null
br i1 %18, label %26, label %19
19: ; preds = %15, %19
%20 = phi i8* [ %24, %19 ], [ %17, %15 ]
%21 = phi i8** [ %22, %19 ], [ %2, %15 ]
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%24 = load i8*, i8** %22
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %19
26: ; preds = %19, %15
%27 = add nsw i32 %0, -1
ret i32 %27
}