#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 EOF;
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ printf(char *, char, ...);
void main(int argc, char **argv) {
  int c;
  while ((c = getopt(argc, argv, "ab:c:")) != EOF) {
    printf("%c, %s\n", c, optarg);
  }
  printf("%c\n", 'a');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xec3(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
je     1177 <main+0x57>
mov    -0x14(%rbp),%eax
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%rdx
lea    0xe9e(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
lea    0xe90(%rip),%rdi
mov    $0x61,%esi
mov    $0x0,%al
call   1030 <printf@plt>
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>
mov    0x2e9d(%rip),%r12
cmp    (%r12),%eax
je     1184 <main+0x64>
mov    0x2ea8(%rip),%r13
lea    0xeaf(%rip),%r14
lea    0xea2(%rip),%r15
xchg   %ax,%ax
mov    0x0(%r13),%rdx
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <getopt@plt>
cmp    (%r12),%eax
jne    1160 <main+0x40>
lea    0xe83(%rip),%rdi
mov    $0x61,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [6 x i8] c"ab:c:\00"
@EOF = global i32 0
@.str.1 = [8 x i8] c"%c, %s\0A\00"
@optarg = global i8* null
@.str.2 = [4 x i8] c"%c\0A\00"
define void @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2, %6
%7 = phi i32 [ %11, %6 ], [ %3, %2 ]
%8 = trunc i32 %7 to i8
%9 = load i8*, i8** @optarg
%10 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8 signext %8, i8* %9)
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %6
14: ; preds = %6, %2
%15 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext 97)
ret void
}