#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 first(int, int, int);
int /*<<< orphan*/ get1(int *, int *, int *);
int /*<<< orphan*/ get2(int *, int *);
int /*<<< orphan*/ getEnter();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int second(int, int);
int main(void) {
  int value1, value2, value3, operation;
  printf("\033[H\033[J");
  while (1) {
    printf("\033[%d;%dH", (20), (9));
    printf("555 IC calculator\n\n\n");
    printf("\t[0] Exit\n\t[1] Astable    :: Square wave\n\t[2] Monostable :: "
           "Timeout\n\n\n\n\tChoose an operation: ");
    scanf("%d", &operation);
    switch (operation) {
    case 0:
      printf("\033[H\033[J");
      printf("Goodbye\n");
      return 0;
    case 1:
      get1(&value1, &value2, &value3);
      printf("%d", first(value1, value2, value3));
      break;
    case 2:
      get2(&value1, &value2);
      printf("%d", second(value1, value2));
      break;
    default:
      printf("Error: Unrecognized command, try again.");
      getEnter();
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
mov    $0x14,%esi
mov    $0x9,%edx
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     120b <main+0x9b>
jmp    11e9 <main+0x79>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     122f <main+0xbf>
jmp    11fa <main+0x8a>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1263 <main+0xf3>
jmp    1290 <main+0x120>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <get1@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1090 <first@plt>
mov    %eax,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a5 <main+0x135>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <get2@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <second@plt>
mov    %eax,%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a5 <main+0x135>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getEnter@plt>
jmp    118d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe64(%rip),%r14
lea    0xeef(%rip),%r15
lea    0xe5f(%rip),%r12
lea    0xeb6(%rip),%rbx
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbp
jmp    11f6 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   1040 <get2@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1070 <second@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x14,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x1,%eax
je     1250 <main+0xd0>
cmp    $0x2,%eax
je     11d0 <main+0x50>
test   %eax,%eax
je     1278 <main+0xf8>
lea    0xe31(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <getEnter@plt>
jmp    11f6 <main+0x76>
lea    0x8(%rsp),%rdi
mov    %rbp,%rsi
lea    0x14(%rsp),%rdx
call   1060 <get1@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x14(%rsp),%edx
call   10a0 <first@plt>
jmp    11ea <main+0x6a>
lea    0xd81(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.2 = [21 x i8] c"555 IC calculator\0A\0A\0A\00"
@.str.3 = [94 x i8] c"\09[0] Exit\0A\09[1] Astable :: Square wave\0A\09[2] Monostable :: Timeout\0A\0A\0A\0A\09Choose an operation: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [9 x i8] c"Goodbye\0A\00"
@.str.6 = [40 x i8] c"Error: Unrecognized command, try again.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %0, %32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 9)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
switch i32 %12, label %29 [
i32 0, label %13
i32 1, label %16
i32 2, label %23
]
13: ; preds = %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
16: ; preds = %7
%17 = call i32 @get1(i32* %2, i32* %3, i32* %4)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 @first(i32 %18, i32 %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %32
23: ; preds = %7
%24 = call i32 @get2(i32* %2, i32* %3)
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @second(i32 %25, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %32
29: ; preds = %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 (...) @getEnter()
br label %32
32: ; preds = %29, %23, %16
br label %7
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [9 x i8] c"\1B[%d;%dH\00"
@.str.3 = [94 x i8] c"\09[0] Exit\0A\09[1] Astable :: Square wave\0A\09[2] Monostable :: Timeout\0A\0A\0A\0A\09Choose an operation: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [40 x i8] c"Error: Unrecognized command, try again.\00"
@str = [20 x i8] c"555 IC calculator\0A\0A\00"
@str.7 = [8 x i8] c"Goodbye\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %35, %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 9)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%15 = load i32, i32* %4
switch i32 %15, label %32 [
i32 0, label %16
i32 1, label %19
i32 2, label %26
]
16: ; preds = %10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.7, i64 0, i64 0))
ret i32 0
19: ; preds = %10
%20 = call i32 @get1(i32* %1, i32* %2, i32* %3)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @first(i32 %21, i32 %22, i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %24)
br label %35
26: ; preds = %10
%27 = call i32 @get2(i32* %1, i32* %2)
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @second(i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %30)
br label %35
32: ; preds = %10
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (...) @getEnter()
br label %35
35: ; preds = %32, %26, %19
br label %10
}