#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 *, int, char *);
void printargv(char **argv) {
  for (; *argv != 0; argv++) {
    int argc = 0;
    for (; *argv != 0; argv++, argc++)
      printf("argv[%d]=\"%s\"\n", argc, *argv);
    argc++;
  }
}


x86 assembly (clang, -O0):
<printargv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1189 <printargv+0x79>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     116f <printargv+0x5f>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <printargv+0x21>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <printargv+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printargv>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%rdx
test   %rdx,%rdx
je     1162 <printargv+0x52>
xor    %ebp,%ebp
lea    0xedb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdi,%rbx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0x8(%rbx),%rdi
add    $0x1,%ebp
mov    0x8(%rbx),%rdx
test   %rdx,%rdx
jne    1130 <printargv+0x20>
mov    0x10(%rbx),%rdx
add    $0x10,%rbx
mov    $0x0,%ebp
mov    %rbx,%rdi
test   %rdx,%rdx
jne    1130 <printargv+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"argv[%d]=\22%s\22\0A\00"
define void @printargv(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
store i8** %0, i8*** %2
br label %4
4: ; preds = %26, %1
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %29
8: ; preds = %4
store i32 0, i32* %3
br label %9
9: ; preds = %18, %8
%10 = load i8**, i8*** %2
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32, i32* %3
%15 = load i8**, i8*** %2
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %16)
br label %18
18: ; preds = %13
%19 = load i8**, i8*** %2
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %2
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %9
23: ; preds = %9
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %26
26: ; preds = %23
%27 = load i8**, i8*** %2
%28 = getelementptr inbounds i8*, i8** %27, i32 1
store i8** %28, i8*** %2
br label %4
29: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"argv[%d]=\22%s\22\0A\00"
define void @printargv(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %21, label %4
4: ; preds = %1, %13
%5 = phi i32 [ %14, %13 ], [ 0, %1 ]
%6 = phi i8** [ %15, %13 ], [ %0, %1 ]
%7 = phi i8* [ %16, %13 ], [ %2, %1 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %7)
%9 = getelementptr inbounds i8*, i8** %6, i64 1
%10 = add nuw nsw i32 %5, 1
%11 = load i8*, i8** %9
%12 = icmp eq i8* %11, null
br i1 %12, label %17, label %13
13: ; preds = %4, %17
%14 = phi i32 [ %10, %4 ], [ 0, %17 ]
%15 = phi i8** [ %9, %4 ], [ %18, %17 ]
%16 = phi i8* [ %11, %4 ], [ %19, %17 ]
br label %4
17: ; preds = %4
%18 = getelementptr inbounds i8*, i8** %6, i64 2
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %13
21: ; preds = %17, %1
ret void
}