#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 *, ...);
void debug_print_argv(char **argv) {
  printf("ARGV:\n");
  for (; *argv != NULL; *argv++) {
    printf("  %s\n", *argv);
  }
  printf("--\n\n");
}


x86 assembly (clang, -O0):
<debug_print_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     115e <debug_print_argv+0x4e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    112a <debug_print_argv+0x1a>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_print_argv>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     1166 <debug_print_argv+0x46>
add    $0x8,%rbx
lea    0xeba(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1150 <debug_print_argv+0x30>
lea    0xe9f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"ARGV:\0A\00"
@.str.1 = [6 x i8] c" %s\0A\00"
@.str.2 = [5 x i8] c"--\0A\0A\00"
define void @debug_print_argv(i8** %0) {
%2 = alloca i8**
store i8** %0, i8*** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %12, %1
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = load i8**, i8*** %2
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8
%13 = load i8**, i8*** %2
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %2
%15 = load i8*, i8** %13
br label %4
16: ; preds = %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c" %s\0A\00"
@str = [6 x i8] c"ARGV:\00"
@str.3 = [4 x i8] c"--\0A\00"
define void @debug_print_argv(i8** nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %12, label %5
5: ; preds = %1, %5
%6 = phi i8* [ %10, %5 ], [ %3, %1 ]
%7 = phi i8** [ %9, %5 ], [ %0, %1 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = getelementptr inbounds i8*, i8** %7, i64 1
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %5
12: ; preds = %5, %1
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0))
ret void
}