#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main(int argc, char *argv[]) {
  int num;
  int denom;
  float skewamount;
  if (argc == 1) {
    return 0;
  }
  int mode = atoi(argv[1]);
  while (true) {
    printf("Change Timeskew: _________\033[9D");
    if (mode == 0) {
      scanf("%f", &skewamount);
      num = (int)(skewamount * 1000);
      denom = 1000;
    }
    if (mode == 1) {
      scanf("%i %i", &num, &denom);
    }
    FILE *tsf = fopen("/tmp/.timeskew", "w");
    if (tsf) {
      fprintf(tsf, "%i %i", num, denom);
      fclose(tsf);
    } else {
      printf("Could not start realtime time editing.\n");
      return 2;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1262 <main+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x20(%rbp)
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x20(%rbp)
jne    11df <main+0x7f>
lea    0xe6a(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movss  0xe34(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movl   $0x3e8,-0x18(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11ff <main+0x9f>
lea    0xe36(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
lea    0xe26(%rip),%rdi
lea    0xe2c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1245 <main+0xe5>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xdf4(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    125d <main+0xfd>
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1262 <main+0x102>
jmp    119c <main+0x3c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
cmp    $0x1,%edi
je     1266 <main+0xf6>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
lea    0xe69(%rip),%r14
lea    0xe84(%rip),%r15
lea    0xe83(%rip),%rbp
lea    0xe89(%rip),%r12
mov    %r14,%rdi
call   1050 <printf@plt>
cmp    $0x1,%ebx
je     1200 <main+0x90>
test   %ebx,%ebx
jne    1214 <main+0xa4>
lea    0xe5b(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x14(%rsp),%xmm0
mulss  0xe1e(%rip),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,0x10(%rsp)
movl   $0x3e8,0xc(%rsp)
jmp    1214 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1247 <main+0xd7>
mov    %rax,%r13
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
jmp    11b0 <main+0x40>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Change Timeskew: _________\1B[9D\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"%i %i\00"
@.str.3 = [15 x i8] c"/tmp/.timeskew\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [40 x i8] c"Could not start realtime time editing.\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 float
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %47
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %9
br label %19
19: ; preds = %14, %46
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %8)
%25 = load float, float* %8
%26 = fmul float %25, 1.000000e+03
%27 = fptosi float %26 to i32
store i32 %27, i32* %6
store i32 1000, i32* %7
br label %28
28: ; preds = %23, %19
%29 = load i32, i32* %9
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %6, i32* %7)
br label %33
33: ; preds = %31, %28
%34 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %34, i32** %10
%35 = load i32*, i32** %10
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i32*, i32** %10
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
%42 = load i32*, i32** %10
%43 = call i32 @fclose(i32* %42)
br label %46
44: ; preds = %33
%45 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %47
46: ; preds = %37
br label %19
47: ; preds = %44, %13
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [31 x i8] c"Change Timeskew: _________\1B[9D\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [6 x i8] c"%i %i\00"
@.str.3 = [15 x i8] c"/tmp/.timeskew\00"
@.str.4 = [2 x i8] c"w\00"
@str = [39 x i8] c"Could not start realtime time editing.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast float* %5 to i8*
%9 = icmp eq i32 %0, 1
br i1 %9, label %33, label %10
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
br label %14
14: ; preds = %28, %10
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %23 [
i32 0, label %16
i32 1, label %21
]
16: ; preds = %14
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%18 = load float, float* %5
%19 = fmul float %18, 1.000000e+03
%20 = fptosi float %19 to i32
store i32 %20, i32* %3
store i32 1000, i32* %4
br label %23
21: ; preds = %14
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
br label %23
23: ; preds = %16, %14, %21
%24 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %33
28: ; preds = %23
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
%32 = call i32 @fclose(i32* %24)
br label %14
33: ; preds = %26, %2
%34 = phi i32 [ 0, %2 ], [ 2, %26 ]
ret i32 %34
}