#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 */
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ printf(char *);
int read_args(int argc, char **argv, int *flag_Re, double *Re,
              double *viscosity, int *mc_id, int *imax, int *jmax,
              double *rho) {
  if (argc == 6) {
    *flag_Re = atoi(argv[1]);
    if (*flag_Re == 1) {
      *Re = atof(argv[2]);
      if (*Re <= 0) {
        printf("Reynolds number must be greater than zero.");
        return 0;
      }
    } else {
      *viscosity = atof(argv[2]);
      if (*viscosity <= 0) {
        printf("Viscosity number must be greater than zero.");
        return 0;
      }
      *Re = (2 * (*rho) * 1) / (*viscosity);
    }
    *mc_id = atoi(argv[3]);
    if (*mc_id < 0) {
      printf("Monte Carlo ID must be positive.");
      return 0;
    }
    *imax = atoi(argv[4]);
    if (*imax < 0) {
      printf("imax must be a positive integer.");
      return 0;
    }
    *jmax = atoi(argv[5]);
    if (*jmax < 0) {
      printf("jmax must be a positive integer.");
      return 0;
    }
  } else {
    printf("Please pass the correct number and type of arguments (Re, MC_ID, "
           "imax, jmax).");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x6,-0x8(%rbp)
jne    12e7 <read_args+0x1b7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jne    11ca <read_args+0x9a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     11c5 <read_args+0x95>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
jmp    1234 <read_args+0x104>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     1208 <read_args+0xd8>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
mov    0x20(%rbp),%rax
movsd  0xdf4(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  0xde0(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jge    126e <read_args+0x13e>
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    12a8 <read_args+0x178>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jge    12e2 <read_args+0x1b2>
lea    0xdd8(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
jmp    12ff <read_args+0x1cf>
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1306 <read_args+0x1d6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x6,%edi
jne    1185 <read_args+0x55>
mov    %r9,%r14
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r13
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %eax,(%rbx)
mov    0x10(%r13),%rdi
call   1030 <atof@plt>
cmp    $0x1,%ebp
jne    1191 <read_args+0x61>
movsd  %xmm0,(%r15)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jb     11b7 <read_args+0x87>
lea    0xe80(%rip),%rdi
jmp    1218 <read_args+0xe8>
lea    0xf2e(%rip),%rdi
jmp    1218 <read_args+0xe8>
movsd  %xmm0,(%r12)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    11ff <read_args+0xcf>
mov    0x50(%rsp),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
mov    0x18(%r13),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
test   %eax,%eax
js     1208 <read_args+0xd8>
mov    0x40(%rsp),%rbx
mov    0x20(%r13),%rdi
call   1050 <atoi@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     1211 <read_args+0xe1>
mov    0x48(%rsp),%rbx
mov    0x28(%r13),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    %eax,(%rbx)
mov    $0x1,%eax
test   %ecx,%ecx
jns    121f <read_args+0xef>
lea    0xe9c(%rip),%rdi
jmp    1218 <read_args+0xe8>
lea    0xe25(%rip),%rdi
jmp    1218 <read_args+0xe8>
lea    0xe48(%rip),%rdi
jmp    1218 <read_args+0xe8>
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Reynolds number must be greater than zero.\00"
@.str.1 = [44 x i8] c"Viscosity number must be greater than zero.\00"
@.str.2 = [33 x i8] c"Monte Carlo ID must be positive.\00"
@.str.3 = [33 x i8] c"imax must be a positive integer.\00"
@.str.4 = [33 x i8] c"jmax must be a positive integer.\00"
@.str.5 = [78 x i8] c"Please pass the correct number and type of arguments (Re, MC_ID, imax, jmax).\00"
define i32 @read_args(i32 %0, i8** %1, i32* %2, double* %3, double* %4, i32* %5, i32* %6, i32* %7, double* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i32*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca double*
store i32 %0, i32* %11
store i8** %1, i8*** %12
store i32* %2, i32** %13
store double* %3, double** %14
store double* %4, double** %15
store i32* %5, i32** %16
store i32* %6, i32** %17
store i32* %7, i32** %18
store double* %8, double** %19
%20 = load i32, i32* %11
%21 = icmp eq i32 %20, 6
br i1 %21, label %22, label %97
22: ; preds = %9
%23 = load i8**, i8*** %12
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = load i32*, i32** %13
store i32 %26, i32* %27
%28 = load i32*, i32** %13
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %43
31: ; preds = %22
%32 = load i8**, i8*** %12
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call double @atof(i8* %34)
%36 = load double*, double** %14
store double %35, double* %36
%37 = load double*, double** %14
%38 = load double, double* %37
%39 = fcmp ole double %38, 0.000000e+00
br i1 %39, label %40, label %42
40: ; preds = %31
%41 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %100
42: ; preds = %31
br label %63
43: ; preds = %22
%44 = load i8**, i8*** %12
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call double @atof(i8* %46)
%48 = load double*, double** %15
store double %47, double* %48
%49 = load double*, double** %15
%50 = load double, double* %49
%51 = fcmp ole double %50, 0.000000e+00
br i1 %51, label %52, label %54
52: ; preds = %43
%53 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
br label %100
54: ; preds = %43
%55 = load double*, double** %19
%56 = load double, double* %55
%57 = fmul double 2.000000e+00, %56
%58 = fmul double %57, 1.000000e+00
%59 = load double*, double** %15
%60 = load double, double* %59
%61 = fdiv double %58, %60
%62 = load double*, double** %14
store double %61, double* %62
br label %63
63: ; preds = %54, %42
%64 = load i8**, i8*** %12
%65 = getelementptr inbounds i8*, i8** %64, i64 3
%66 = load i8*, i8** %65
%67 = call i32 @atoi(i8* %66)
%68 = load i32*, i32** %16
store i32 %67, i32* %68
%69 = load i32*, i32** %16
%70 = load i32, i32* %69
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %63
%73 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %10
br label %100
74: ; preds = %63
%75 = load i8**, i8*** %12
%76 = getelementptr inbounds i8*, i8** %75, i64 4
%77 = load i8*, i8** %76
%78 = call i32 @atoi(i8* %77)
%79 = load i32*, i32** %17
store i32 %78, i32* %79
%80 = load i32*, i32** %17
%81 = load i32, i32* %80
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %74
%84 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %100
85: ; preds = %74
%86 = load i8**, i8*** %12
%87 = getelementptr inbounds i8*, i8** %86, i64 5
%88 = load i8*, i8** %87
%89 = call i32 @atoi(i8* %88)
%90 = load i32*, i32** %18
store i32 %89, i32* %90
%91 = load i32*, i32** %18
%92 = load i32, i32* %91
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %85
%95 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %10
br label %100
96: ; preds = %85
br label %99
97: ; preds = %9
%98 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %100
99: ; preds = %96
store i32 1, i32* %10
br label %100
100: ; preds = %99, %97, %94, %83, %72, %52, %40
%101 = load i32, i32* %10
ret i32 %101
}

LLVM IR (-O2):
@.str = [43 x i8] c"Reynolds number must be greater than zero.\00"
@.str.1 = [44 x i8] c"Viscosity number must be greater than zero.\00"
@.str.2 = [33 x i8] c"Monte Carlo ID must be positive.\00"
@.str.3 = [33 x i8] c"imax must be a positive integer.\00"
@.str.4 = [33 x i8] c"jmax must be a positive integer.\00"
@.str.5 = [78 x i8] c"Please pass the correct number and type of arguments (Re, MC_ID, imax, jmax).\00"
define i32 @read_args(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, double* nocapture writeonly %3, double* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i32* nocapture writeonly %7, double* nocapture %8) {
%10 = icmp eq i32 %0, 6
br i1 %10, label %11, label %42
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* %2
%15 = icmp eq i32 %14, 1
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call double @atof(i8* %17)
br i1 %15, label %19, label %21
19: ; preds = %11
store double %18, double* %3
%20 = fcmp ugt double %18, 0.000000e+00
br i1 %20, label %27, label %42
21: ; preds = %11
store double %18, double* %4
%22 = fcmp ugt double %18, 0.000000e+00
br i1 %22, label %23, label %42
23: ; preds = %21
%24 = load double, double* %8
%25 = fmul double %24, 2.000000e+00
%26 = fdiv double %25, %18
store double %26, double* %3
br label %27
27: ; preds = %19, %23
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
store i32 %30, i32* %5
%31 = icmp slt i32 %30, 0
br i1 %31, label %42, label %32
32: ; preds = %27
%33 = getelementptr inbounds i8*, i8** %1, i64 4
%34 = load i8*, i8** %33
%35 = tail call i32 @atoi(i8* %34)
store i32 %35, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %32
%38 = getelementptr inbounds i8*, i8** %1, i64 5
%39 = load i8*, i8** %38
%40 = tail call i32 @atoi(i8* %39)
store i32 %40, i32* %7
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %9, %37, %32, %27, %21, %19
%43 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), %19 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), %21 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), %27 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), %32 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), %37 ], [ getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0), %9 ]
%44 = tail call i32 @printf(i8* dereferenceable(1) %43)
br label %45
45: ; preds = %42, %37
%46 = phi i32 [ 1, %37 ], [ 0, %42 ]
ret i32 %46
}