#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*/ builtin_invopt(char **);
int /*<<< orphan*/ history_clear();
int /*<<< orphan*/ history_print();
int shell_getopt(int, char **, char *);
int builtin_history(int argc, char *argv[]) {
  int c;
  int clear = 0;
  while ((c = shell_getopt(argc, argv, "c")) > 0) {
    switch (c) {
    case 'c':
      clear = 1;
      break;
    default:
      builtin_invopt(argv);
      return 1;
    }
  }
  if (clear)
    history_clear();
  else
    history_print();
  return 0;
}


x86 assembly (clang, -O0):
<builtin_history>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9c(%rip),%rdx
call   1060 <shell_getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11ac <builtin_history+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x63,%eax
jne    1192 <builtin_history+0x52>
jmp    1186 <builtin_history+0x46>
movl   $0x1,-0x18(%rbp)
jmp    11a7 <builtin_history+0x67>
mov    -0x10(%rbp),%rdi
call   1050 <builtin_invopt@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <builtin_history+0x90>
jmp    1156 <builtin_history+0x16>
cmpl   $0x0,-0x18(%rbp)
je     11c2 <builtin_history+0x82>
mov    $0x0,%al
call   1030 <history_clear@plt>
jmp    11c9 <builtin_history+0x89>
mov    $0x0,%al
call   1040 <history_print@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_history>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb0(%rip),%rdx
call   1060 <shell_getopt@plt>
test   %eax,%eax
jle    1181 <builtin_history+0x41>
lea    0xea0(%rip),%r14
cmp    $0x63,%eax
jne    118c <builtin_history+0x4c>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <shell_getopt@plt>
test   %eax,%eax
jg     1160 <builtin_history+0x20>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <history_clear@plt>
jmp    1199 <builtin_history+0x59>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <history_print@plt>
jmp    1199 <builtin_history+0x59>
mov    %rbx,%rdi
call   1050 <builtin_invopt@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"c\00"
define i32 @builtin_history(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @shell_getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* %6
switch i32 %14, label %16 [
i32 99, label %15
]
15: ; preds = %13
store i32 1, i32* %7
br label %19
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = call i32 @builtin_invopt(i8** %17)
store i32 1, i32* %3
br label %28
19: ; preds = %15
br label %8
20: ; preds = %8
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (...) @history_clear()
br label %27
25: ; preds = %20
%26 = call i32 (...) @history_print()
br label %27
27: ; preds = %25, %23
store i32 0, i32* %3
br label %28
28: ; preds = %27, %16
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"c\00"
define i32 @builtin_history(i32 %0, i8** %1) {
%3 = tail call i32 @shell_getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp sgt i32 %3, 0
br i1 %4, label %8, label %15
5: ; preds = %8
%6 = tail call i32 @shell_getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %2, %5
%9 = phi i32 [ %6, %5 ], [ %3, %2 ]
%10 = icmp eq i32 %9, 99
br i1 %10, label %5, label %11
11: ; preds = %8
%12 = tail call i32 @builtin_invopt(i8** %1)
br label %17
13: ; preds = %5
%14 = tail call i32 (...) @history_clear()
br label %17
15: ; preds = %2
%16 = tail call i32 (...) @history_print()
br label %17
17: ; preds = %13, %15, %11
%18 = phi i32 [ 1, %11 ], [ 0, %15 ], [ 0, %13 ]
ret i32 %18
}