#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 */
struct timespec {
  int dummy;
};

/* Variables and functions */
double currenttime(struct timespec);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ time;
int main(int argc, char *argv[]) {
  int refreshtime = 0;
  struct timespec rawtime;
  double oldtime, starttime, stoptime;
  char command[118];
  char aplay[19];
  while (1) {
    if (!oldtime > 1)
      oldtime = 0.000000;
    printf("[GPS] %lf\n", time);
    sprintf(command,
            "echo \"|START|%lf|%d_%d|%d|END\" | sudo ./minimodem --tx -8 -f %s "
            "%d --space %d --mark %d",
            oldtime, 300, 600, 1, "send.wav", 60, 20250, 20300);
    printf("[GPS] %s\n", command);
    system(command);
    oldtime = currenttime(rawtime);
    starttime = currenttime(rawtime);
    sprintf(aplay, "sudo aplay %s -f S16_LE", "send.wav");
    system(aplay);
    stoptime = currenttime(rawtime);
    if ((8 - (stoptime - starttime)) > 0) {
      sleep(8 - (stoptime - starttime));
      printf("[GPS] sleeping...\n");
      sleep(14);
    } else {
      printf("[GPS] sleeping...\n");
      sleep(14 + (8 - (stoptime - starttime)));
    }
    refreshtime++;
    if (refreshtime >= 100) {
      printf("this is supposed to refresh the time");
      system(
          "sudo service ntp stop && sudo ntpd -qg && sudo service ntp start");
      refreshtime = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
jle    119c <main+0x4c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xb0(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe55(%rip),%rsi
mov    $0x12c,%edx
mov    $0x258,%ecx
mov    $0x1,%r8d
lea    0xe96(%rip),%r9
movl   $0x3c,(%rsp)
movl   $0x4f1a,0x8(%rsp)
movl   $0x4f4c,0x10(%rsp)
mov    $0x1,%al
call   1060 <sprintf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <system@plt>
mov    -0x18(%rbp),%edi
call   1030 <currenttime@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <currenttime@plt>
movsd  %xmm0,-0x28(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xe42(%rip),%rsi
lea    0xe28(%rip),%rdx
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0xd0(%rbp),%rdi
call   1040 <system@plt>
mov    -0x18(%rbp),%edi
call   1030 <currenttime@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  0xd83(%rip),%xmm0
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ca <main+0x17a>
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  0xd60(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sleep@plt>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xe,%edi
call   1070 <sleep@plt>
jmp    1303 <main+0x1b3>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xd16(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0xd12(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jl     1337 <main+0x1e7>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdab(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x14(%rbp)
jmp    1170 <main+0x20>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
lea    0xf03(%rip),%r12
lea    0x30(%rsp),%rbx
lea    0xf0a(%rip),%rbp
lea    0x10(%rsp),%r14
lea    0xf7c(%rip),%r15
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0xe5e(%rip),%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x12c,%edx
mov    $0x258,%ecx
mov    $0x1,%r8d
mov    %r12,%r9
mov    $0x1,%al
push   $0x4f4c
push   $0x4f1a
push   $0x3c
call   1070 <sprintf@plt>
add    $0x20,%rsp
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
call   1040 <currenttime@plt>
movsd  %xmm0,0x8(%rsp)
call   1040 <currenttime@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
call   1040 <currenttime@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0xdaf(%rip),%xmm1
movsd  %xmm1,(%rsp)
ucomisd 0xdb2(%rip),%xmm1
jbe    1280 <main+0x120>
cvttsd2si (%rsp),%edi
call   1080 <sleep@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0xe,%edi
jmp    1299 <main+0x139>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
addsd  0xd73(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sleep@plt>
lea    0x1(%r13),%eax
cmp    $0x63,%r13d
mov    %eax,%r13d
jl     11a0 <main+0x40>
xor    %r13d,%r13d
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe04(%rip),%rdi
call   1050 <system@plt>
jmp    11a0 <main+0x40>

LLVM IR (-O0):
%struct.timespec = type { i32 }
@.str = [11 x i8] c"[GPS] %lf\0A\00"
@time = global i32 0
@.str.1 = [88 x i8] c"echo \22|START|%lf|%d_%d|%d|END\22 | sudo ./minimodem --tx -8 -f %s %d --space %d --mark %d\00"
@.str.2 = [9 x i8] c"send.wav\00"
@.str.3 = [10 x i8] c"[GPS] %s\0A\00"
@.str.4 = [24 x i8] c"sudo aplay %s -f S16_LE\00"
@.str.5 = [19 x i8] c"[GPS] sleeping...\0A\00"
@.str.6 = [37 x i8] c"this is supposed to refresh the time\00"
@.str.7 = [65 x i8] c"sudo service ntp stop && sudo ntpd -qg && sudo service ntp start\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.timespec
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [118 x i8]
%12 = alloca [19 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %13
13: ; preds = %2, %74
%14 = load double, double* %8
%15 = fcmp une double %14, 0.000000e+00
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %13
store double 0.000000e+00, double* %8
br label %20
20: ; preds = %19, %13
%21 = load i32, i32* @time
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [118 x i8], [118 x i8]* %11, i64 0, i64 0
%24 = load double, double* %8
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), double %24, i32 300, i32 600, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 60, i32 20250, i32 20300)
%26 = getelementptr inbounds [118 x i8], [118 x i8]* %11, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [118 x i8], [118 x i8]* %11, i64 0, i64 0
%29 = call i32 @system(i8* %28)
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call double @currenttime(i32 %31)
store double %32, double* %8
%33 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call double @currenttime(i32 %34)
store double %35, double* %9
%36 = getelementptr inbounds [19 x i8], [19 x i8]* %12, i64 0, i64 0
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [19 x i8], [19 x i8]* %12, i64 0, i64 0
%39 = call i32 @system(i8* %38)
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call double @currenttime(i32 %41)
store double %42, double* %10
%43 = load double, double* %10
%44 = load double, double* %9
%45 = fsub double %43, %44
%46 = fsub double 8.000000e+00, %45
%47 = fcmp ogt double %46, 0.000000e+00
br i1 %47, label %48, label %57
48: ; preds = %20
%49 = load double, double* %10
%50 = load double, double* %9
%51 = fsub double %49, %50
%52 = fsub double 8.000000e+00, %51
%53 = fptosi double %52 to i32
%54 = call i32 @sleep(i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @sleep(i32 14)
br label %66
57: ; preds = %20
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%59 = load double, double* %10
%60 = load double, double* %9
%61 = fsub double %59, %60
%62 = fsub double 8.000000e+00, %61
%63 = fadd double 1.400000e+01, %62
%64 = fptosi double %63 to i32
%65 = call i32 @sleep(i32 %64)
br label %66
66: ; preds = %57, %48
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
%69 = load i32, i32* %6
%70 = icmp sge i32 %69, 100
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%73 = call i32 @system(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %6
br label %74
74: ; preds = %71, %66
br label %13
}

LLVM IR (-O2):
@.str = [11 x i8] c"[GPS] %lf\0A\00"
@time = global i32 0
@.str.1 = [88 x i8] c"echo \22|START|%lf|%d_%d|%d|END\22 | sudo ./minimodem --tx -8 -f %s %d --space %d --mark %d\00"
@.str.2 = [9 x i8] c"send.wav\00"
@.str.3 = [10 x i8] c"[GPS] %s\0A\00"
@.str.4 = [24 x i8] c"sudo aplay %s -f S16_LE\00"
@.str.6 = [37 x i8] c"this is supposed to refresh the time\00"
@.str.7 = [65 x i8] c"sudo service ntp stop && sudo ntpd -qg && sudo service ntp start\00"
@str.8 = [18 x i8] c"[GPS] sleeping...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [118 x i8]
%4 = alloca [19 x i8]
%5 = getelementptr inbounds [118 x i8], [118 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %39, %2
%8 = phi double [ undef, %2 ], [ %15, %39 ]
%9 = phi i32 [ 0, %2 ], [ %40, %39 ]
%10 = load i32, i32* @time
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), double %8, i32 300, i32 600, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 60, i32 20250, i32 20300)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%14 = call i32 @system(i8* %5)
%15 = call double @currenttime(i32 undef)
%16 = call double @currenttime(i32 undef)
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @system(i8* %6)
%19 = call double @currenttime(i32 undef)
%20 = fsub double %16, %19
%21 = fadd double %20, 8.000000e+00
%22 = fcmp ogt double %21, 0.000000e+00
br i1 %22, label %23, label %27
23: ; preds = %7
%24 = fptosi double %21 to i32
%25 = call i32 @sleep(i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
br label %31
27: ; preds = %7
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%29 = fadd double %21, 1.400000e+01
%30 = fptosi double %29 to i32
br label %31
31: ; preds = %27, %23
%32 = phi i32 [ %30, %27 ], [ 14, %23 ]
%33 = call i32 @sleep(i32 %32)
%34 = add nsw i32 %9, 1
%35 = icmp sgt i32 %9, 98
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 @system(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %36, %31
%40 = phi i32 [ 0, %36 ], [ %34, %31 ]
br label %7
}