#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ start_downcounting(int);
int /*<<< orphan*/ start_randomcounting(int);
int /*<<< orphan*/ start_upcounting(int);
int /*<<< orphan*/ start_updowncounting(int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  printf("Application for up/down/random counter on 7 seg display\n");
  if (argc != 3) {
    printf("usage: %s <direction> <delay>\n", argv[0]);
    printf("valid direction : up, down, updown, random\n");
    printf("recommended delay range in ms : 0 to 1000\n");
  } else {
    int delay_value = atoi(argv[2]);
    if (!strcmp(argv[1], "up")) {
      start_upcounting(delay_value);
    } else if (strcmp(argv[1], "down") == 0) {
      start_downcounting(delay_value);
    } else if (strcmp(argv[1], "updown") == 0) {
      start_updowncounting(delay_value);
    } else if (strcmp(argv[1], "random") == 0) {
      start_randomcounting(delay_value);
    } else {
      printf("Invalid direction values\n");
      printf("valid direction values : up, down,updown,random\n");
    }
  }
}


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)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     11d4 <main+0x64>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c0 <main+0x150>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xebc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120f <main+0x9f>
mov    -0x14(%rbp),%edi
call   1080 <start_upcounting@plt>
jmp    12bb <main+0x14b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe96(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    123a <main+0xca>
mov    -0x14(%rbp),%edi
call   1040 <start_downcounting@plt>
jmp    12b6 <main+0x146>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <main+0xf5>
mov    -0x14(%rbp),%edi
call   1070 <start_updowncounting@plt>
jmp    12b1 <main+0x141>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1290 <main+0x120>
mov    -0x14(%rbp),%edi
call   1060 <start_randomcounting@plt>
jmp    12ac <main+0x13c>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b1 <main+0x141>
jmp    12b6 <main+0x146>
jmp    12bb <main+0x14b>
jmp    12c0 <main+0x150>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x3,%ebp
jne    120d <main+0x8d>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
lea    0xe70(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1238 <main+0xb8>
mov    0x8(%rbx),%rdi
lea    0xe60(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1241 <main+0xc1>
mov    0x8(%rbx),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     124a <main+0xca>
mov    0x8(%rbx),%rdi
lea    0xee0(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1253 <main+0xd3>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6f(%rip),%rdi
jmp    1231 <main+0xb1>
mov    (%rbx),%rsi
lea    0xde9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
jmp    125a <main+0xda>
mov    %ebp,%edi
call   1090 <start_upcounting@plt>
jmp    125a <main+0xda>
mov    %ebp,%edi
call   1050 <start_downcounting@plt>
jmp    125a <main+0xda>
mov    %ebp,%edi
call   1080 <start_updowncounting@plt>
jmp    125a <main+0xda>
mov    %ebp,%edi
call   1070 <start_randomcounting@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Application for up/down/random counter on 7 seg display\0A\00"
@.str.1 = [31 x i8] c"usage: %s <direction> <delay>\0A\00"
@.str.2 = [44 x i8] c"valid direction : up, down, updown, random\0A\00"
@.str.3 = [43 x i8] c"recommended delay range in ms : 0 to 1000\0A\00"
@.str.4 = [3 x i8] c"up\00"
@.str.5 = [5 x i8] c"down\00"
@.str.6 = [7 x i8] c"updown\00"
@.str.7 = [7 x i8] c"random\00"
@.str.8 = [26 x i8] c"Invalid direction values\0A\00"
@.str.9 = [49 x i8] c"valid direction values : up, down,updown,random\0A\00"
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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %64
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %17
%28 = load i32, i32* %6
%29 = call i32 @start_upcounting(i32 %28)
br label %63
30: ; preds = %17
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %6
%38 = call i32 @start_downcounting(i32 %37)
br label %62
39: ; preds = %30
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %39
%46 = load i32, i32* %6
%47 = call i32 @start_updowncounting(i32 %46)
br label %61
48: ; preds = %39
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = load i32, i32* %6
%56 = call i32 @start_randomcounting(i32 %55)
br label %60
57: ; preds = %48
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
br label %60
60: ; preds = %57, %54
br label %61
61: ; preds = %60, %45
br label %62
62: ; preds = %61, %36
br label %63
63: ; preds = %62, %27
br label %64
64: ; preds = %63, %10
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"usage: %s <direction> <delay>\0A\00"
@.str.4 = [3 x i8] c"up\00"
@.str.5 = [5 x i8] c"down\00"
@.str.6 = [7 x i8] c"updown\00"
@.str.7 = [7 x i8] c"random\00"
@str = [56 x i8] c"Application for up/down/random counter on 7 seg display\00"
@str.10 = [25 x i8] c"Invalid direction values\00"
@str.11 = [48 x i8] c"valid direction values : up, down,updown,random\00"
@str.12 = [43 x i8] c"valid direction : up, down, updown, random\00"
@str.13 = [42 x i8] c"recommended delay range in ms : 0 to 1000\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32 %0, 3
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.13, i64 0, i64 0))
br label %41
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = tail call i32 @start_upcounting(i32 %13)
br label %41
20: ; preds = %10
%21 = load i8*, i8** %14
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @start_downcounting(i32 %13)
br label %41
26: ; preds = %20
%27 = load i8*, i8** %14
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 @start_updowncounting(i32 %13)
br label %41
32: ; preds = %26
%33 = load i8*, i8** %14
%34 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = tail call i32 @start_randomcounting(i32 %13)
br label %41
38: ; preds = %32
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0))
br label %41
41: ; preds = %18, %30, %38, %36, %24, %5
ret i32 0
}