#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 */
char EOF;
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char getopt(int, char **, char *);
int /*<<< orphan*/ help();
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
void lorenz(int argc, char *argv[]) {
  int N = 80;
  char ch;
  while ((ch = getopt(argc, argv, "hN:")) != EOF)
    switch (ch) {
    case 'N':
      N = atoi(optarg);
      break;
    case 'h':
      help();
      break;
    default:
      fprintf(stderr, "Unknown option for lorenz: '%s'\n", optarg);
      help();
    }
  argc -= optind;
  argv += optind;
  double x = 1, y = 1, z = 1;
  double dx = 0, dy = 0, dz = 0;
  double T = 0.01;
  long int n = 0;
  for (; n < N; n++) {
    dx = 10 * (y - x);
    dy = 28 * x - y - x * z;
    dz = 28 * x * y - (8 * z / 3.0);
    x = x + T * dx;
    y = y + T * dy;
    z = z + T * dz;
    printf("%.6f\n", x);
  }
}


x86 assembly (clang, -O0):
<lorenz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x50,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xebc(%rip),%rdx
call   1050 <getopt@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e5a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1205 <lorenz+0xb5>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x4e,%eax
je     11b7 <lorenz+0x67>
jmp    11a6 <lorenz+0x56>
mov    -0x5c(%rbp),%eax
sub    $0x68,%eax
je     11ce <lorenz+0x7e>
jmp    11da <lorenz+0x8a>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1200 <lorenz+0xb0>
mov    $0x0,%al
call   1060 <help@plt>
jmp    1200 <lorenz+0xb0>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%rdx
lea    0xe40(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <help@plt>
jmp    1166 <lorenz+0x16>
mov    0x2dcc(%rip),%rax
mov    (%rax),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    0x2db8(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movsd  0xdd1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdc4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdb7(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd8a(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jge    13d3 <lorenz+0x283>
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xd82(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd48(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd0a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xcf0(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
movsd  0xcdb(%rip),%xmm3
divsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xc98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1283 <lorenz+0x133>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lorenz>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
lea    0xef5(%rip),%rdx
call   1050 <getopt@plt>
mov    0x2e69(%rip),%r13
mov    $0x50,%ebp
cmp    0x0(%r13),%al
je     11fb <lorenz+0xab>
mov    $0x50,%r15d
lea    0xed1(%rip),%r14
mov    0x2e62(%rip),%rbp
jmp    11d4 <lorenz+0x84>
nopl   0x0(%rax,%rax,1)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xeb0(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <help@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    0x0(%r13),%al
je     11ef <lorenz+0x9f>
movsbl %al,%eax
cmp    $0x68,%eax
je     11b9 <lorenz+0x69>
cmp    $0x4e,%eax
jne    11a0 <lorenz+0x50>
mov    0x0(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
jmp    11c0 <lorenz+0x70>
test   %r15d,%r15d
jle    12c5 <lorenz+0x175>
movslq %r15d,%rbp
movapd 0xdfd(%rip),%xmm5
movsd  0xe25(%rip),%xmm6
lea    0xe73(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm5,%xmm0
unpckhpd %xmm5,%xmm0
movapd %xmm6,%xmm1
mulsd  0xe0c(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
subsd  %xmm6,%xmm0
mulsd  0xdf0(%rip),%xmm0
movapd %xmm6,%xmm3
xorpd  0xdbc(%rip),%xmm3
movapd %xmm5,%xmm4
mulsd  0xde8(%rip),%xmm4
divsd  0xde8(%rip),%xmm4
unpcklpd %xmm2,%xmm4
unpcklpd %xmm3,%xmm1
movapd %xmm5,%xmm2
shufpd $0x1,%xmm5,%xmm2
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulsd  0xdcf(%rip),%xmm0
addsd  %xmm0,%xmm6
movapd %xmm6,(%rsp)
mulpd  0xd86(%rip),%xmm2
addpd  %xmm2,%xmm5
movapd %xmm5,0x10(%rsp)
mov    %rbx,%rdi
movapd %xmm6,%xmm0
call   1030 <printf@plt>
movapd (%rsp),%xmm6
movapd 0x10(%rsp),%xmm5
add    $0xffffffffffffffff,%rbp
jne    1220 <lorenz+0xd0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [33 x i8] c"Unknown option for lorenz: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @lorenz(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 80, i32* %5
br label %15
15: ; preds = %36, %2
%16 = load i32, i32* %3
%17 = load i8**, i8*** %4
%18 = call signext i8 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8 %18, i8* %6
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %37
23: ; preds = %15
%24 = load i8, i8* %6
%25 = sext i8 %24 to i32
switch i32 %25, label %31 [
i32 78, label %26
i32 104, label %29
]
26: ; preds = %23
%27 = load i8*, i8** @optarg
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %5
br label %36
29: ; preds = %23
%30 = call i32 (...) @help()
br label %36
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = load i8*, i8** @optarg
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = call i32 (...) @help()
br label %36
36: ; preds = %31, %29, %26
br label %15
37: ; preds = %15
%38 = load i64, i64* @optind
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = sub nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %3
%43 = load i64, i64* @optind
%44 = load i8**, i8*** %4
%45 = getelementptr inbounds i8*, i8** %44, i64 %43
store i8** %45, i8*** %4
store double 1.000000e+00, double* %7
store double 1.000000e+00, double* %8
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 1.000000e-02, double* %13
store i64 0, i64* %14
br label %46
46: ; preds = %86, %37
%47 = load i64, i64* %14
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %51, label %89
51: ; preds = %46
%52 = load double, double* %8
%53 = load double, double* %7
%54 = fsub double %52, %53
%55 = fmul double 1.000000e+01, %54
store double %55, double* %10
%56 = load double, double* %7
%57 = load double, double* %8
%58 = fneg double %57
%59 = call double @llvm.fmuladd.f64(double 2.800000e+01, double %56, double %58)
%60 = load double, double* %7
%61 = load double, double* %9
%62 = fneg double %60
%63 = call double @llvm.fmuladd.f64(double %62, double %61, double %59)
store double %63, double* %11
%64 = load double, double* %7
%65 = fmul double 2.800000e+01, %64
%66 = load double, double* %8
%67 = load double, double* %9
%68 = fmul double 8.000000e+00, %67
%69 = fdiv double %68, 3.000000e+00
%70 = fneg double %69
%71 = call double @llvm.fmuladd.f64(double %65, double %66, double %70)
store double %71, double* %12
%72 = load double, double* %7
%73 = load double, double* %13
%74 = load double, double* %10
%75 = call double @llvm.fmuladd.f64(double %73, double %74, double %72)
store double %75, double* %7
%76 = load double, double* %8
%77 = load double, double* %13
%78 = load double, double* %11
%79 = call double @llvm.fmuladd.f64(double %77, double %78, double %76)
store double %79, double* %8
%80 = load double, double* %9
%81 = load double, double* %13
%82 = load double, double* %12
%83 = call double @llvm.fmuladd.f64(double %81, double %82, double %80)
store double %83, double* %9
%84 = load double, double* %7
%85 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %84)
br label %86
86: ; preds = %51
%87 = load i64, i64* %14
%88 = add nsw i64 %87, 1
store i64 %88, i64* %14
br label %46
89: ; preds = %46
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"hN:\00"
@EOF = global i8 0
@optarg = global i8* null
@stderr = global i32 0
@.str.1 = [33 x i8] c"Unknown option for lorenz: '%s'\0A\00"
@optind = global i64 0
@.str.2 = [6 x i8] c"%.6f\0A\00"
define void @lorenz(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %9, label %11
6: ; preds = %25
%7 = sext i32 %26 to i64
%8 = icmp sgt i32 %26, 0
br i1 %8, label %9, label %55
9: ; preds = %2, %6
%10 = phi i64 [ %7, %6 ], [ 80, %2 ]
br label %30
11: ; preds = %2, %25
%12 = phi i8 [ %27, %25 ], [ %3, %2 ]
%13 = phi i32 [ %26, %25 ], [ 80, %2 ]
%14 = sext i8 %12 to i32
switch i32 %14, label %20 [
i32 78, label %15
i32 104, label %18
]
15: ; preds = %11
%16 = load i8*, i8** @optarg
%17 = tail call i32 @atoi(i8* %16)
br label %25
18: ; preds = %11
%19 = tail call i32 (...) @help()
br label %25
20: ; preds = %11
%21 = load i32, i32* @stderr
%22 = load i8*, i8** @optarg
%23 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = tail call i32 (...) @help()
br label %25
25: ; preds = %20, %18, %15
%26 = phi i32 [ %13, %20 ], [ %13, %18 ], [ %17, %15 ]
%27 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%28 = load i8, i8* @EOF
%29 = icmp eq i8 %27, %28
br i1 %29, label %6, label %11
30: ; preds = %9, %30
%31 = phi i64 [ %53, %30 ], [ 0, %9 ]
%32 = phi double [ %50, %30 ], [ 1.000000e+00, %9 ]
%33 = phi <2 x double> [ %51, %30 ], [ <double 1.000000e+00, double 1.000000e+00>, %9 ]
%34 = extractelement <2 x double> %33, i64 1
%35 = fsub double %34, %32
%36 = fmul double %35, 1.000000e+01
%37 = fneg double %34
%38 = tail call double @llvm.fmuladd.f64(double %32, double 2.800000e+01, double %37)
%39 = fneg double %32
%40 = fmul double %32, 2.800000e+01
%41 = extractelement <2 x double> %33, i64 0
%42 = fmul double %41, 8.000000e+00
%43 = fdiv double %42, -3.000000e+00
%44 = insertelement <2 x double> poison, double %40, i64 0
%45 = insertelement <2 x double> %44, double %39, i64 1
%46 = shufflevector <2 x double> %33, <2 x double> undef, <2 x i32> <i32 1, i32 0>
%47 = insertelement <2 x double> poison, double %43, i64 0
%48 = insertelement <2 x double> %47, double %38, i64 1
%49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %45, <2 x double> %46, <2 x double> %48)
%50 = tail call double @llvm.fmuladd.f64(double %36, double 1.000000e-02, double %32)
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %49, <2 x double> <double 1.000000e-02, double 1.000000e-02>, <2 x double> %33)
%52 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %50)
%53 = add nuw nsw i64 %31, 1
%54 = icmp eq i64 %53, %10
br i1 %54, label %55, label %30
55: ; preds = %30, %6
ret void
}