#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 lancio(int, int);
int /*<<< orphan*/ menu(int *, int *);
int /*<<< orphan*/ print_usange();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  srand(time(NULL));
  int dado = 0;
  int tiri = 1;
  int res = 0;
  int cow = 0;
  char cow_c[] = "cow";
  if (argc == 2 || argc > 4) {
    print_usange();
    return -1;
  }
  if (argc == 4)
    if (strcmp(argv[3], cow_c) == 0) {
      cow = 1;
    }
  if (argc == 3) {
    if (sscanf(argv[1], "%i", &dado) != 1) {
      printf("ERRORE - Il valore del dado non e' un numero!\n\n");
      return -1;
    }
    if (sscanf(argv[2], "%i", &tiri) != 1) {
      printf("ERRORE - Il valore dei tiri non e' un numero!\n\n");
      return -1;
    }
  } else
    menu(&dado, &tiri);
  res = lancio(tiri, dado);
  if (cow) {
    char cow_say[30];
    sprintf(cow_say, "cowsay Somma dei tiri: %i", res);
    system(cow_say);
  } else
    printf("\nSomma dei tiri: %i\n\n", res);
  printf("\n");
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0xe18(%rip),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ff <main+0x5f>
cmpl   $0x4,-0x8(%rbp)
jle    1212 <main+0x72>
mov    $0x0,%al
call   1070 <print_usange@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1333 <main+0x193>
cmpl   $0x4,-0x8(%rbp)
jne    1243 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x24(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    123e <main+0x9e>
movl   $0x1,-0x20(%rbp)
jmp    1243 <main+0xa3>
cmpl   $0x3,-0x8(%rbp)
jne    12c8 <main+0x128>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1f(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     1288 <main+0xe8>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1333 <main+0x193>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde4(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x1,%eax
je     12c3 <main+0x123>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1333 <main+0x193>
jmp    12d5 <main+0x135>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <menu@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10c0 <lancio@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     130e <main+0x16e>
lea    -0x50(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xd69(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x50(%rbp),%rdi
call   1040 <system@plt>
jmp    131f <main+0x17f>
mov    -0x1c(%rbp),%esi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
movl   $0x0,0x8(%rsp)
movl   $0x1,0x4(%rsp)
movl   $0x776f63,0xc(%rsp)
cmp    $0x2,%ebp
je     1262 <main+0xa2>
cmp    $0x5,%ebp
jge    1262 <main+0xa2>
cmp    $0x3,%ebp
je     1270 <main+0xb0>
mov    $0x1,%r14b
cmp    $0x4,%ebp
jne    121f <main+0x5f>
mov    0x18(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
setne  %r14b
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1050 <menu@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <lancio@plt>
mov    %eax,%ebx
test   %r14b,%r14b
jne    12b3 <main+0xf3>
lea    0xdb7(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <system@plt>
jmp    12c3 <main+0x103>
xor    %eax,%eax
call   1090 <print_usange@plt>
mov    $0xffffffff,%ebx
jmp    12cd <main+0x10d>
mov    0x8(%rbx),%rdi
lea    0xd9c(%rip),%rsi
lea    0x8(%rsp),%rdx
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12d8 <main+0x118>
mov    0x10(%rbx),%rdi
lea    0xd82(%rip),%rsi
lea    0x4(%rsp),%rdx
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12e1 <main+0x121>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <lancio@plt>
mov    %eax,%ebx
lea    0xd60(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd80(%rip),%rdi
jmp    12e8 <main+0x128>
lea    0xd48(%rip),%rdi
call   1040 <puts@plt>
jmp    1269 <main+0xa9>

LLVM IR (-O0):
@__const.main.cow_c = [4 x i8] c"cow\00"
@.str = [3 x i8] c"%i\00"
@.str.1 = [48 x i8] c"ERRORE - Il valore del dado non e' un numero!\0A\0A\00"
@.str.2 = [48 x i8] c"ERRORE - Il valore dei tiri non e' un numero!\0A\0A\00"
@.str.3 = [26 x i8] c"cowsay Somma dei tiri: %i\00"
@.str.4 = [22 x i8] c"\0ASomma dei tiri: %i\0A\0A\00"
@.str.5 = [2 x i8] c"\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 i32
%10 = alloca [4 x i8]
%11 = alloca [30 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
store i32 0, i32* %6
store i32 1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%14 = bitcast [4 x i8]* %10 to i8*
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 2
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 4
br i1 %19, label %20, label %22
20: ; preds = %17, %2
%21 = call i32 (...) @print_usange()
store i32 -1, i32* %3
br label %74
22: ; preds = %17
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 4
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %10, i64 0, i64 0
%30 = call i64 @strcmp(i8* %28, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 1, i32* %9
br label %33
33: ; preds = %32, %25
br label %34
34: ; preds = %33, %22
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %54
37: ; preds = %34
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%42 = icmp ne i32 %41, 1
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %74
45: ; preds = %37
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @sscanf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%50 = icmp ne i32 %49, 1
br i1 %50, label %51, label %53
51: ; preds = %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %74
53: ; preds = %45
br label %56
54: ; preds = %34
%55 = call i32 @menu(i32* %6, i32* %7)
br label %56
56: ; preds = %54, %53
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = call i32 @lancio(i32 %57, i32 %58)
store i32 %59, i32* %8
%60 = load i32, i32* %9
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %56
%63 = getelementptr inbounds [30 x i8], [30 x i8]* %11, i64 0, i64 0
%64 = load i32, i32* %8
%65 = call i32 @sprintf(i8* %63, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [30 x i8], [30 x i8]* %11, i64 0, i64 0
%67 = call i32 @system(i8* %66)
br label %71
68: ; preds = %56
%69 = load i32, i32* %8
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %68, %62
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%73 = load i32, i32* %8
store i32 %73, i32* %3
br label %74
74: ; preds = %71, %51, %43, %20
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.3 = [26 x i8] c"cowsay Somma dei tiri: %i\00"
@.str.4 = [22 x i8] c"\0ASomma dei tiri: %i\0A\0A\00"
@str = [47 x i8] c"ERRORE - Il valore dei tiri non e' un numero!\0A\00"
@str.6 = [47 x i8] c"ERRORE - Il valore del dado non e' un numero!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [30 x i8]
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 1, i32* %4
%11 = bitcast i32* %5 to i8*
store i32 7827299, i32* %5
%12 = icmp eq i32 %0, 2
%13 = icmp sgt i32 %0, 4
%14 = or i1 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = tail call i32 (...) @print_usange()
br label %57
17: ; preds = %2
switch i32 %0, label %41 [
i32 4, label %18
i32 3, label %23
]
18: ; preds = %17
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* %11)
%22 = icmp ne i64 %21, 0
br label %41
23: ; preds = %17
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%27 = icmp eq i32 %26, 1
br i1 %27, label %30, label %28
28: ; preds = %23
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.6, i64 0, i64 0))
br label %57
30: ; preds = %23
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @sscanf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load i32, i32* %4
%37 = load i32, i32* %3
%38 = call i32 @lancio(i32 %36, i32 %37)
br label %51
39: ; preds = %30
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %57
41: ; preds = %17, %18
%42 = phi i1 [ %22, %18 ], [ true, %17 ]
%43 = call i32 @menu(i32* %3, i32* %4)
%44 = load i32, i32* %4
%45 = load i32, i32* %3
%46 = call i32 @lancio(i32 %44, i32 %45)
br i1 %42, label %51, label %47
47: ; preds = %41
%48 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%49 = call i32 @sprintf(i8* %48, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%50 = call i32 @system(i8* %48)
br label %54
51: ; preds = %35, %41
%52 = phi i32 [ %38, %35 ], [ %46, %41 ]
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %51, %47
%55 = phi i32 [ %52, %51 ], [ %46, %47 ]
%56 = call i32 @putchar(i32 10)
br label %57
57: ; preds = %54, %39, %28, %15
%58 = phi i32 [ -1, %15 ], [ -1, %28 ], [ -1, %39 ], [ %55, %54 ]
ret i32 %58
}