#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
float exp(float);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
float log(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int view, nview;
  char filename[128];
  float mu1 = 0., mu2 = 6., density, afac, s;
  FILE *fp = (FILE *)NULL;
  if (argc != 4) {
    fprintf(stderr, "Usage: %s iview nview phmfilename\n", argv[0]);
    exit(1);
  }
  view = atoi(argv[1]);
  nview = atoi(argv[2]);
  sprintf(filename, "%s", argv[3]);
  s = (float)view / ((float)(nview - 1));
  if (s < 7. / 16.)
    density = mu1;
  else if (s > 9. / 16.)
    density = mu2;
  else {
    afac = ((s - 7. / 16.) / 2. / 16.);
    density = log(1 / ((1 - afac) * exp(-mu1) + afac * exp(-mu2)));
  }
  if ((fp = fopen(filename, "w")) == (FILE *)NULL) {
    fprintf(stderr, "Error, can not open file \"tmpphmfile\"\n");
    exit(2);
  }
  fprintf(fp, "rectangle 0 0 11.5 11.5 0 0\n");
  fprintf(fp, "ellipse   0 0 11.4 11.4 0 1\n");
  fprintf(fp, "ellipse   0 0 1.25 1.25 0 %f\n", density);
  fclose(fp);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xa4(%rbp)
ff
movss  0xe54(%rip),%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
movq   $0x0,-0xc0(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11f2 <main+0x72>
mov    0x2e10(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xe23(%rip),%rsi
call   1090 <sprintf@plt>
cvtsi2ssl -0x14(%rbp),%xmm0
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xb4(%rbp)
ff
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movsd  0xdac(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    127b <main+0xfb>
movss  -0xa4(%rbp),%xmm0
ff
movss  %xmm0,-0xac(%rbp)
ff
jmp    1397 <main+0x217>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xd81(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12ae <main+0x12e>
movss  -0xa8(%rbp),%xmm0
ff
movss  %xmm0,-0xac(%rbp)
ff
jmp    1392 <main+0x212>
movss  -0xb4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xd46(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xd52(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd3e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xb0(%rbp)
ff
movss  0xd12(%rip),%xmm0
subss  -0xb0(%rbp),%xmm0
ff
movss  %xmm0,-0xcc(%rbp)
ff
movss  -0xa4(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <exp@plt>
movss  %xmm0,-0xc8(%rbp)
ff
movss  -0xb0(%rbp),%xmm0
ff
movss  %xmm0,-0xc4(%rbp)
ff
movss  -0xa8(%rbp),%xmm0
ff
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1050 <exp@plt>
movss  -0xcc(%rbp),%xmm1
ff
movss  -0xc8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movss  -0xc4(%rbp),%xmm0
ff
mulss  %xmm3,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xc87(%rip),%xmm0
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <log@plt>
movss  %xmm0,-0xac(%rbp)
ff
jmp    1397 <main+0x217>
lea    -0xa0(%rbp),%rdi
lea    0xca9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xc0(%rbp)
cmp    $0x0,%rax
jne    13dd <main+0x25d>
mov    0x2c1e(%rip),%rax
movslq (%rax),%rdi
lea    0xc84(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
mov    -0xc0(%rbp),%rdi
lea    0xc8c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc0(%rbp),%rdi
lea    0xc94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0xc0(%rbp),%rdi
movss  -0xac(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xc90(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0xc0(%rbp),%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    11ef <main+0x6f>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcpy@plt>
cvtsi2ss %r14d,%xmm0
add    $0xffffffff,%ebp
cvtsi2ss %ebp,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm2,%xmm2
movss  0xe2d(%rip),%xmm1
ucomiss %xmm0,%xmm1
ja     1263 <main+0xe3>
ucomiss 0xe21(%rip),%xmm0
jbe    1214 <main+0x94>
movsd  0xe23(%rip),%xmm2
jmp    1263 <main+0xe3>
mov    0x2dea(%rip),%rax
movslq (%rax),%rdi
mov    (%rbx),%rdx
lea    0xe2d(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cvtss2sd %xmm0,%xmm0
addsd  0xdf8(%rip),%xmm0
mulsd  0xdf8(%rip),%xmm0
mulsd  0xdf8(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0xdcc(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm0,%xmm2
mulss  0xdc1(%rip),%xmm0
addss  %xmm2,%xmm0
divss  %xmm0,%xmm1
cvttss2si %xmm1,%edi
call   1060 <log@plt>
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
lea    0xde3(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1070 <fopen@plt>
test   %rax,%rax
jne    12a9 <main+0x129>
mov    0x2d5a(%rip),%rax
movslq (%rax),%rcx
lea    0xdc5(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    %rax,%rbx
lea    0xdc9(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10a0 <fwrite@plt>
lea    0xdcd(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xdd1(%rip),%rsi
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s iview nview phmfilename\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [39 x i8] c"Error, can not open file \22tmpphmfile\22\0A\00"
@.str.4 = [29 x i8] c"rectangle 0 0 11.5 11.5 0 0\0A\00"
@.str.5 = [29 x i8] c"ellipse 0 0 11.4 11.4 0 1\0A\00"
@.str.6 = [30 x i8] c"ellipse 0 0 1.25 1.25 0 %f\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 [128 x i8]
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %9
store float 6.000000e+00, float* %10
store i32* null, i32** %14
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 4
br i1 %16, label %17, label %26
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %6
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %7
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %6
%41 = sitofp i32 %40 to float
%42 = load i32, i32* %7
%43 = sub nsw i32 %42, 1
%44 = sitofp i32 %43 to float
%45 = fdiv float %41, %44
store float %45, float* %13
%46 = load float, float* %13
%47 = fpext float %46 to double
%48 = fcmp olt double %47, 4.375000e-01
br i1 %48, label %49, label %51
49: ; preds = %26
%50 = load float, float* %9
store float %50, float* %11
br label %79
51: ; preds = %26
%52 = load float, float* %13
%53 = fpext float %52 to double
%54 = fcmp ogt double %53, 5.625000e-01
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = load float, float* %10
store float %56, float* %11
br label %78
57: ; preds = %51
%58 = load float, float* %13
%59 = fpext float %58 to double
%60 = fsub double %59, 4.375000e-01
%61 = fdiv double %60, 2.000000e+00
%62 = fdiv double %61, 1.600000e+01
%63 = fptrunc double %62 to float
store float %63, float* %12
%64 = load float, float* %12
%65 = fsub float 1.000000e+00, %64
%66 = load float, float* %9
%67 = fneg float %66
%68 = call float @exp(float %67)
%69 = load float, float* %12
%70 = load float, float* %10
%71 = fneg float %70
%72 = call float @exp(float %71)
%73 = fmul float %69, %72
%74 = call float @llvm.fmuladd.f32(float %65, float %68, float %73)
%75 = fdiv float 1.000000e+00, %74
%76 = fptosi float %75 to i32
%77 = call float @log(i32 %76)
store float %77, float* %11
br label %78
78: ; preds = %57, %55
br label %79
79: ; preds = %78, %49
%80 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%81 = call i32* @fopen(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %81, i32** %14
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %89
83: ; preds = %79
%84 = load i32, i32* @stderr
%85 = sext i32 %84 to i64
%86 = inttoptr i64 %85 to i32*
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%88 = call i32 @exit(i32 2)
unreachable
89: ; preds = %79
%90 = load i32*, i32** %14
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%92 = load i32*, i32** %14
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%94 = load i32*, i32** %14
%95 = load float, float* %11
%96 = fpext float %95 to double
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), double %96)
%98 = load i32*, i32** %14
%99 = call i32 @fclose(i32* %98)
%100 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: %s iview nview phmfilename\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [39 x i8] c"Error, can not open file \22tmpphmfile\22\0A\00"
@.str.4 = [29 x i8] c"rectangle 0 0 11.5 11.5 0 0\0A\00"
@.str.5 = [29 x i8] c"ellipse 0 0 11.4 11.4 0 1\0A\00"
@.str.6 = [30 x i8] c"ellipse 0 0 1.25 1.25 0 %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = load i8*, i8** %1
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %21)
%23 = sitofp i32 %16 to float
%24 = add nsw i32 %19, -1
%25 = sitofp i32 %24 to float
%26 = fdiv float %23, %25
%27 = fpext float %26 to double
%28 = fcmp olt float %26, 4.375000e-01
br i1 %28, label %43, label %29
29: ; preds = %13
%30 = fcmp ogt float %26, 5.625000e-01
br i1 %30, label %43, label %31
31: ; preds = %29
%32 = fadd double %27, -4.375000e-01
%33 = fmul double %32, 5.000000e-01
%34 = fmul double %33, 6.250000e-02
%35 = fptrunc double %34 to float
%36 = fsub float 1.000000e+00, %35
%37 = fmul float %35, 0x3F644E5200000000
%38 = fadd float %36, %37
%39 = fdiv float 1.000000e+00, %38
%40 = fptosi float %39 to i32
%41 = call float @log(i32 %40)
%42 = fpext float %41 to double
br label %43
43: ; preds = %29, %13, %31
%44 = phi double [ %42, %31 ], [ 0.000000e+00, %13 ], [ 6.000000e+00, %29 ]
%45 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %53
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
%51 = call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i64 38, i64 1, i32* %50)
%52 = call i32 @exit(i32 2)
unreachable
53: ; preds = %43
%54 = call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i64 28, i64 1, i32* %45)
%55 = call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i64 28, i64 1, i32* %45)
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), double %44)
%57 = call i32 @fclose(i32* %45)
%58 = call i32 @exit(i32 0)
unreachable
}