#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
double strtod(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ system(char *);
char *tmpl_insert(char *, int, double);
int main(int argc, char *argv[]) {
  if (argc != 5) {
    fputs("invocation: ./genpmovie.x <cmd with %f and %d> <min> <step> <num>",
          stderr);
    exit(1);
  }
  char *cmd_tmpl = argv[1];
  double min = strtod(argv[2], NULL);
  double step = strtod(argv[3], NULL);
  int num = atoi(argv[4]);
  for (int i = 0; i < num; i++) {
    char *cmd = tmpl_insert(cmd_tmpl, i, min + i * step);
    printf(">>> %s\n", cmd);
    system(cmd);
    free(cmd);
  }
}


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   $0x5,-0x8(%rbp)
je     11bf <main+0x3f>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
lea    0xe50(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1271 <main+0xf1>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <tmpl_insert@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <system@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    120e <main+0x8e>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x5,%edi
jne    1245 <main+0xc5>
mov    %rsi,%rbp
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x20(%rbp),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    1236 <main+0xb6>
mov    %eax,%r12d
xorpd  %xmm0,%xmm0
lea    0xe6f(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
call   1080 <tmpl_insert@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1050 <system@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xdd2(%rip),%xmm0
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    11e0 <main+0x60>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
lea    0xdb3(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [66 x i8] c"invocation: ./genpmovie.x <cmd with %f and %d> <min> <step> <num>\00"
@stderr = global i32 0
@.str.1 = [8 x i8] c">>> %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fputs(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call double @strtod(i8* %24, i32* null)
store double %25, double* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
%29 = call double @strtod(i8* %28, i32* null)
store double %29, double* %8
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 4
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %9
store i32 0, i32* %10
br label %34
34: ; preds = %53, %18
%35 = load i32, i32* %10
%36 = load i32, i32* %9
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %56
38: ; preds = %34
%39 = load i8*, i8** %6
%40 = load i32, i32* %10
%41 = load double, double* %7
%42 = load i32, i32* %10
%43 = sitofp i32 %42 to double
%44 = load double, double* %8
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double %41)
%46 = call i8* @tmpl_insert(i8* %39, i32 %40, double %45)
store i8* %46, i8** %11
%47 = load i8*, i8** %11
%48 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %11
%50 = call i32 @system(i8* %49)
%51 = load i8*, i8** %11
%52 = call i32 @free(i8* %51)
br label %53
53: ; preds = %38
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %34
56: ; preds = %34
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [66 x i8] c"invocation: ./genpmovie.x <cmd with %f and %d> <min> <step> <num>\00"
@stderr = global i32 0
@.str.1 = [8 x i8] c">>> %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 5
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call double @strtod(i8* nocapture %12, i32* null)
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call double @strtod(i8* nocapture %15, i32* null)
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %22, %8
ret i32 0
22: ; preds = %8, %22
%23 = phi i32 [ %30, %22 ], [ 0, %8 ]
%24 = sitofp i32 %23 to double
%25 = tail call double @llvm.fmuladd.f64(double %24, double %16, double %13)
%26 = tail call i8* @tmpl_insert(i8* %10, i32 %23, double %25)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = tail call i32 @system(i8* %26)
%29 = tail call i32 @free(i8* %26)
%30 = add nuw nsw i32 %23, 1
%31 = icmp eq i32 %30, %19
br i1 %31, label %21, label %22
}