#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ md_cleanup(double *, double *);
scalar_t__ md_init(unsigned int, double *, double *, double, double);
scalar_t__ md_read(char *, unsigned int, double *, double *, double, double);
int /*<<< orphan*/ md_run(int, double *, double *, double, double);
int /*<<< orphan*/ md_write(char *, unsigned int, double *, double *, double,
                            double);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char);
int main(int argc, char **argv) {
  if (argc <= 2) {
    printf("usage:\n"
           "%s i number_of_particles\n"
           "%s c dump_file.dat\n"
           "i = init.\n"
           "c = continue\n",
           argv[0], argv[0]);
    return 0;
  }
  double *x;
  double *v;
  unsigned iNumPart;
  double dBoxX;
  double dBoxY;
  if (strcmp(argv[1], 'i') == 0) {
    iNumPart = atoi(argv[2]);
    if (md_init(iNumPart, x, v, dBoxX, dBoxY) == 0)
      return 1;
  } else {
    if (md_read(argv[2], iNumPart, x, v, dBoxX, dBoxY) == 0)
      return 1;
  }
  md_run(1000, x, v, dBoxX, dBoxY);
  md_write("md.dumb", iNumPart, x, v, dBoxX, dBoxY);
  md_cleanup(x, v);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     11c6 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b5 <main+0x135>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x69,%esi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1227 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1080 <md_init@plt>
cmp    $0x0,%rax
jne    1222 <main+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x135>
jmp    1264 <main+0xe4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <md_read@plt>
cmp    $0x0,%rax
jne    125f <main+0xdf>
movl   $0x1,-0x4(%rbp)
jmp    12b5 <main+0x135>
jmp    1264 <main+0xe4>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mov    $0x3e8,%edi
call   1090 <md_run@plt>
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xdaf(%rip),%rdi
call   1060 <md_write@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <md_cleanup@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     119d <main+0x1d>
mov    (%rbx),%rdx
lea    0xe6d(%rip),%rdi
mov    %rdx,%rsi
call   1030 <printf@plt>
jmp    11db <main+0x5b>
mov    0x8(%rbx),%rdi
mov    $0x69,%esi
call   1050 <strcmp@plt>
mov    0x10(%rbx),%rdi
test   %rax,%rax
je     11df <main+0x5f>
call   1040 <md_read@plt>
test   %rax,%rax
je     11f2 <main+0x72>
mov    $0x3e8,%edi
call   1090 <md_run@plt>
lea    0xe7c(%rip),%rdi
mov    %ebx,%esi
call   1060 <md_write@plt>
call   10a0 <md_cleanup@plt>
xor    %eax,%eax
pop    %rbx
ret
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <md_init@plt>
test   %rax,%rax
jne    11be <main+0x3e>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [75 x i8] c"usage:\0A%s i number_of_particles\0A%s c dump_file.dat\0Ai = init.\0Ac = continue\0A\00"
@.str.1 = [8 x i8] c"md.dumb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 2
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %19)
store i32 0, i32* %3
br label %69
21: ; preds = %2
%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 signext 105)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %21
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = load double*, double** %6
%34 = load double*, double** %7
%35 = load double, double* %9
%36 = load double, double* %10
%37 = call i64 @md_init(i32 %32, double* %33, double* %34, double %35, double %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %27
store i32 1, i32* %3
br label %69
40: ; preds = %27
br label %54
41: ; preds = %21
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = load i32, i32* %8
%46 = load double*, double** %6
%47 = load double*, double** %7
%48 = load double, double* %9
%49 = load double, double* %10
%50 = call i64 @md_read(i8* %44, i32 %45, double* %46, double* %47, double %48, double %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %41
store i32 1, i32* %3
br label %69
53: ; preds = %41
br label %54
54: ; preds = %53, %40
%55 = load double*, double** %6
%56 = load double*, double** %7
%57 = load double, double* %9
%58 = load double, double* %10
%59 = call i32 @md_run(i32 1000, double* %55, double* %56, double %57, double %58)
%60 = load i32, i32* %8
%61 = load double*, double** %6
%62 = load double*, double** %7
%63 = load double, double* %9
%64 = load double, double* %10
%65 = call i32 @md_write(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %60, double* %61, double* %62, double %63, double %64)
%66 = load double*, double** %6
%67 = load double*, double** %7
%68 = call i32 @md_cleanup(double* %66, double* %67)
store i32 0, i32* %3
br label %69
69: ; preds = %54, %52, %39, %13
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [75 x i8] c"usage:\0A%s i number_of_particles\0A%s c dump_file.dat\0Ai = init.\0Ac = continue\0A\00"
@.str.1 = [8 x i8] c"md.dumb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %5)
br label %26
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8 signext 105)
%11 = icmp eq i64 %10, 0
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
br i1 %11, label %14, label %18
14: ; preds = %7
%15 = tail call i32 @atoi(i8* %13)
%16 = tail call i64 @md_init(i32 %15, double* undef, double* undef, double undef, double undef)
%17 = icmp eq i64 %16, 0
br i1 %17, label %26, label %21
18: ; preds = %7
%19 = tail call i64 @md_read(i8* %13, i32 undef, double* undef, double* undef, double undef, double undef)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %18, %14
%22 = phi i32 [ %15, %14 ], [ undef, %18 ]
%23 = tail call i32 @md_run(i32 1000, double* undef, double* undef, double undef, double undef)
%24 = tail call i32 @md_write(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %22, double* undef, double* undef, double undef, double undef)
%25 = tail call i32 @md_cleanup(double* undef, double* undef)
br label %26
26: ; preds = %21, %14, %18, %4
%27 = phi i32 [ 0, %4 ], [ 0, %21 ], [ 1, %14 ], [ 1, %18 ]
ret i32 %27
}