#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 getopt(int, char **, char *);
int /*<<< orphan*/ m_opt();
int /*<<< orphan*/ my_who();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ q_opt();
int main(int argc, char *argv[]) {
  int mflag = 0, qflag = 0, opterr = 0;
  char *cvalue = NULL;
  int c;
  printf("enter while\n");
  while ((c = getopt(argc, argv, "mq")) != -1) {
    printf("debut switch\n");
    switch (c) {
    case 'm':
      mflag = 1;
      printf("mflag %d\n", mflag);
      break;
    case 'q':
      qflag = 1;
      printf("qflag %d\n", qflag);
      break;
    default:
      printf("error\n");
      break;
    }
  }
  if (mflag == 1) {
    printf("if1\n");
    m_opt();
  }
  if (qflag == 1) {
    printf("if2\n");
    q_opt();
  }
  if (mflag == 0 && qflag == 0) {
    printf("if3\n");
    my_who();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1230 <main+0xe0>
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x6d,%eax
je     11e3 <main+0x93>
jmp    11d2 <main+0x82>
mov    -0x30(%rbp),%eax
sub    $0x71,%eax
je     1200 <main+0xb0>
jmp    121d <main+0xcd>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0xdb>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0xdb>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1191 <main+0x41>
cmpl   $0x1,-0x14(%rbp)
jne    124f <main+0xff>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <m_opt@plt>
cmpl   $0x1,-0x18(%rbp)
jne    126e <main+0x11e>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <q_opt@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1297 <main+0x147>
cmpl   $0x0,-0x18(%rbp)
jne    1297 <main+0x147>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <my_who@plt>
xor    %eax,%eax
add    $0x30,%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    0xea0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     125e <main+0xfe>
mov    %eax,%r13d
lea    0xe8f(%rip),%r14
lea    0xe59(%rip),%r12
xor    %r15d,%r15d
movl   $0x0,0x4(%rsp)
jmp    11ee <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%r15d
lea    0xe36(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <getopt@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
je     1221 <main+0xc1>
mov    %r14,%rdi
call   1030 <puts@plt>
cmp    $0x71,%r13d
je     1210 <main+0xb0>
cmp    $0x6d,%r13d
je     11c0 <main+0x60>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
jmp    11d9 <main+0x79>
movl   $0x1,0x4(%rsp)
lea    0xdee(%rip),%rdi
jmp    11cd <main+0x6d>
cmp    $0x1,%r15d
jne    1240 <main+0xe0>
lea    0xdfd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <m_opt@plt>
mov    $0x1,%r15d
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
jne    1263 <main+0x103>
lea    0xdd7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <q_opt@plt>
jmp    127b <main+0x11b>
xor    %eax,%eax
xor    %r15d,%r15d
or     %r15d,%eax
jne    127b <main+0x11b>
lea    0xdb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <my_who@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"enter while\0A\00"
@.str.1 = [3 x i8] c"mq\00"
@.str.2 = [14 x i8] c"debut switch\0A\00"
@.str.3 = [10 x i8] c"mflag %d\0A\00"
@.str.4 = [10 x i8] c"qflag %d\0A\00"
@.str.5 = [7 x i8] c"error\0A\00"
@.str.6 = [5 x i8] c"if1\0A\00"
@.str.7 = [5 x i8] c"if2\0A\00"
@.str.8 = [5 x i8] c"if3\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %28, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %15, i32* %10
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %10
switch i32 %19, label %26 [
i32 109, label %20
i32 113, label %23
]
20: ; preds = %17
store i32 1, i32* %6
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %28
23: ; preds = %17
store i32 1, i32* %7
%24 = load i32, i32* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %28
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %26, %23, %20
br label %12
29: ; preds = %12
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (...) @m_opt()
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%40 = call i32 (...) @q_opt()
br label %41
41: ; preds = %38, %35
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%49 = call i32 (...) @my_who()
br label %50
50: ; preds = %47, %44, %41
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"mq\00"
@.str.3 = [10 x i8] c"mflag %d\0A\00"
@.str.4 = [10 x i8] c"qflag %d\0A\00"
@str = [12 x i8] c"enter while\00"
@str.9 = [4 x i8] c"if3\00"
@str.10 = [4 x i8] c"if2\00"
@str.11 = [4 x i8] c"if1\00"
@str.12 = [13 x i8] c"debut switch\00"
@str.13 = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %33, label %6
6: ; preds = %2, %17
%7 = phi i32 [ %20, %17 ], [ %4, %2 ]
%8 = phi i32 [ %19, %17 ], [ 0, %2 ]
%9 = phi i32 [ %18, %17 ], [ 0, %2 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
switch i32 %7, label %15 [
i32 109, label %11
i32 113, label %13
]
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %17
13: ; preds = %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 1)
br label %17
15: ; preds = %6
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11
%18 = phi i32 [ %9, %15 ], [ 1, %13 ], [ %9, %11 ]
%19 = phi i32 [ %8, %15 ], [ %8, %13 ], [ 1, %11 ]
%20 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %6
22: ; preds = %17
%23 = icmp eq i32 %19, 1
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0))
%26 = tail call i32 (...) @m_opt()
br label %27
27: ; preds = %24, %22
%28 = phi i32 [ 1, %24 ], [ %19, %22 ]
%29 = icmp eq i32 %18, 1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
%32 = tail call i32 (...) @q_opt()
br label %42
33: ; preds = %2, %27
%34 = phi i32 [ %18, %27 ], [ 0, %2 ]
%35 = phi i32 [ %28, %27 ], [ 0, %2 ]
%36 = icmp eq i32 %35, 0
%37 = icmp eq i32 %34, 0
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.9, i64 0, i64 0))
%41 = tail call i32 (...) @my_who()
br label %42
42: ; preds = %30, %39, %33
ret i32 0
}