#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*/ die(char *, char const *const);
char *getarg(char *opt, char ***pargv) {
  const char *const optname = **pargv;
  if (opt)
    return opt;
  if ((opt = *++(*pargv)) == 0)
    die("ERROR: option %s requires a parameter", optname);
  return opt;
}


x86 assembly (clang, -O0):
<getarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <getarg+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <getarg+0x71>
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,(%rcx)
mov    0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1179 <getarg+0x69>
mov    -0x20(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <die@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getarg>:
push   %rax
mov    %rdi,%rax
test   %rdi,%rdi
je     111b <getarg+0xb>
pop    %rcx
ret
mov    %rsi,%rcx
mov    (%rsi),%rax
mov    (%rax),%rsi
lea    0x8(%rax),%rdx
mov    %rdx,(%rcx)
mov    0x8(%rax),%rax
test   %rax,%rax
jne    1119 <getarg+0x9>
lea    0xec5(%rip),%rdi
call   1030 <die@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"ERROR: option %s requires a parameter\00"
define i8* @getarg(i8* %0, i8*** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8***
%6 = alloca i8*
store i8* %0, i8** %4
store i8*** %1, i8**** %5
%7 = load i8***, i8**** %5
%8 = load i8**, i8*** %7
%9 = load i8*, i8** %8
store i8* %9, i8** %6
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i8*, i8** %4
store i8* %13, i8** %3
br label %25
14: ; preds = %2
%15 = load i8***, i8**** %5
%16 = load i8**, i8*** %15
%17 = getelementptr inbounds i8*, i8** %16, i32 1
store i8** %17, i8*** %15
%18 = load i8*, i8** %17
store i8* %18, i8** %4
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %6
%22 = call i32 @die(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %14
%24 = load i8*, i8** %4
store i8* %24, i8** %3
br label %25
25: ; preds = %23, %12
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [38 x i8] c"ERROR: option %s requires a parameter\00"
define i8* @getarg(i8* readnone %0, i8*** nocapture %1) {
%3 = load i8**, i8*** %1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %0, null
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %3, i64 1
store i8** %7, i8*** %1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @die(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %12
12: ; preds = %6, %10, %2
%13 = phi i8* [ %0, %2 ], [ null, %10 ], [ %8, %6 ]
ret i8* %13
}