#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*/ printf(char *, ...);
int readBD(char **);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 2) {
    if (strcmp("--help", argv[1]) == 0) {
      printf("Use: %s name_db host_db user_db pass_db\n", argv[0]);
      printf("name_db: Name of the database. Example: database\n");
      printf("host_db: Host of the database. Example: localhost\n");
      printf("user_db: User of the database. Example: user\n");
      printf("pass_db: Password of the database. Example: password\n");
      return 0;
    }
  }
  if (argc != 5) {
    printf("Error\n");
    printf("Use: %s name_db host_db user_db pass_db\n", argv[0]);
    return -1;
  }
  switch (readBD(argv)) {
  case 1:
    printf("Error: Starting MySQL\n");
    break;
  case 2:
    printf("Error: Connecting to database.\n");
    break;
  case 3:
    printf("Error: Your database is empty.\n");
    break;
  case 0:
    printf("Reading database... OK\n");
    break;
  }
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
jne    11cc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xeb1(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    127f <main+0x14f>
jmp    11cc <main+0x9c>
cmpl   $0x5,-0x8(%rbp)
je     1205 <main+0xd5>
lea    0xf2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127f <main+0x14f>
mov    -0x10(%rbp),%rdi
call   1030 <readBD@plt>
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1278 <main+0x148>
mov    -0x18(%rbp),%rax
lea    0xdd8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1278 <main+0x148>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1278 <main+0x148>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1278 <main+0x148>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x5,%edi
je     118a <main+0x4a>
cmp    $0x2,%edi
jne    1163 <main+0x23>
mov    0x8(%rbx),%rsi
lea    0xeb7(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b4 <main+0x74>
lea    0xf41(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%rsi
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebx
jmp    1212 <main+0xd2>
mov    %rbx,%rdi
call   1030 <readBD@plt>
xor    %ebx,%ebx
cmp    $0x3,%eax
ja     1212 <main+0xd2>
mov    %eax,%eax
lea    0xe5e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8e(%rip),%rdi
jmp    120d <main+0xcd>
mov    (%rbx),%rsi
lea    0xe59(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee3(%rip),%rdi
call   1040 <puts@plt>
lea    0xf08(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf4f(%rip),%rdi
jmp    120d <main+0xcd>
lea    0xe9a(%rip),%rdi
jmp    120d <main+0xcd>
lea    0xe72(%rip),%rdi
jmp    120d <main+0xcd>
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [41 x i8] c"Use: %s name_db host_db user_db pass_db\0A\00"
@.str.2 = [50 x i8] c"name_db: Name of the database. Example: database\0A\00"
@.str.3 = [51 x i8] c"host_db: Host of the database. Example: localhost\0A\00"
@.str.4 = [46 x i8] c"user_db: User of the database. Example: user\0A\00"
@.str.5 = [54 x i8] c"pass_db: Password of the database. Example: password\0A\00"
@.str.6 = [7 x i8] c"Error\0A\00"
@.str.7 = [23 x i8] c"Error: Starting MySQL\0A\00"
@.str.8 = [32 x i8] c"Error: Connecting to database.\0A\00"
@.str.9 = [32 x i8] c"Error: Your database is empty.\0A\00"
@.str.10 = [24 x i8] c"Reading database... OK\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %45
23: ; preds = %8
br label %24
24: ; preds = %23, %2
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 5
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 -1, i32* %3
br label %45
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = call i32 @readBD(i8** %34)
switch i32 %35, label %44 [
i32 1, label %36
i32 2, label %38
i32 3, label %40
i32 0, label %42
]
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %44
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %44
40: ; preds = %33
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
br label %44
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %44
44: ; preds = %33, %42, %40, %38, %36
store i32 0, i32* %3
br label %45
45: ; preds = %44, %27, %14
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.1 = [41 x i8] c"Use: %s name_db host_db user_db pass_db\0A\00"
@str = [23 x i8] c"Reading database... OK\00"
@str.11 = [31 x i8] c"Error: Your database is empty.\00"
@str.12 = [31 x i8] c"Error: Connecting to database.\00"
@str.13 = [22 x i8] c"Error: Starting MySQL\00"
@str.14 = [6 x i8] c"Error\00"
@str.15 = [49 x i8] c"name_db: Name of the database. Example: database\00"
@str.16 = [50 x i8] c"host_db: Host of the database. Example: localhost\00"
@str.17 = [45 x i8] c"user_db: User of the database. Example: user\00"
@str.18 = [53 x i8] c"pass_db: Password of the database. Example: password\00"
define i32 @main(i32 %0, i8** %1) {
switch i32 %0, label %15 [
i32 2, label %3
i32 5, label %19
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %3
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.15, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.16, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.17, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.18, i64 0, i64 0))
br label %29
15: ; preds = %3, %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.14, i64 0, i64 0))
%17 = load i8*, i8** %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %29
19: ; preds = %2
%20 = tail call i32 @readBD(i8** %1)
switch i32 %20, label %29 [
i32 1, label %21
i32 2, label %23
i32 3, label %25
i32 0, label %27
]
21: ; preds = %19
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
br label %29
23: ; preds = %19
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
br label %29
25: ; preds = %19
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
br label %29
27: ; preds = %19
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %21, %23, %25, %27, %19, %15, %8
%30 = phi i32 [ 0, %8 ], [ -1, %15 ], [ 0, %19 ], [ 0, %27 ], [ 0, %25 ], [ 0, %23 ], [ 0, %21 ]
ret i32 %30
}