#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*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ stdout;
int main(int argc, char **args) {
  int op;
  while (0 <= (op = getopt(argc, args, "abc?d:ef:"))) {
    fprintf(stdout, "key: %c value: %s\n", op, optarg);
  }
  return 0;
}


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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebc(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jg     117f <main+0x5f>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    0x2e8d(%rip),%rax
mov    (%rax),%rcx
lea    0xe95(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1136 <main+0x16>
xor    %eax,%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    %rsi,%rbx
mov    %edi,%ebp
lea    0xec9(%rip),%rdx
call   1040 <getopt@plt>
test   %eax,%eax
js     1183 <main+0x63>
mov    0x2e91(%rip),%r12
mov    0x2eaa(%rip),%r13
lea    0xeb5(%rip),%r14
lea    0xea4(%rip),%r15
nopl   0x0(%rax)
mov    (%r12),%edi
mov    0x0(%r13),%rcx
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <getopt@plt>
test   %eax,%eax
jns    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"abc?d:ef:\00"
@stdout = global i32 0
@.str.1 = [19 x i8] c"key: %c value: %s\0A\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %12, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp sle i32 0, %10
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* @stdout
%14 = load i32, i32* %6
%15 = load i8*, i8** @optarg
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* %15)
br label %7
17: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"abc?d:ef:\00"
@stdout = global i32 0
@.str.1 = [19 x i8] c"key: %c value: %s\0A\00"
@optarg = global i8* null
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %12
5: ; preds = %2, %5
%6 = phi i32 [ %10, %5 ], [ %3, %2 ]
%7 = load i32, i32* @stdout
%8 = load i8*, i8** @optarg
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %6, i8* %8)
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = icmp sgt i32 %10, -1
br i1 %11, label %5, label %12
12: ; preds = %5, %2
ret i32 0
}