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

/* Variables and functions */
int /*<<< orphan*/ LOG_WARNING;
char *captureSnapshot(char const *, size_t *);
char *check_for_motion(char const *);
double difference_of_times(struct timeval *, struct timeval *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
char *pathForImage();
char *startOfDataForHTTPRequest(char *);
size_t strlen(char const *);
scalar_t__ strncmp(char *, char const *, size_t);
char *strstr(char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *, ...);
void check_camera(const char *ip, struct timeval *last_capture) {
  char *foo = check_for_motion(ip);
  if (foo) {
    char *data = startOfDataForHTTPRequest(foo);
    if (data) {
      char *instr = strstr(data, "mdresult=");
      if (instr != NULL) {
        const char *noMotionString = "mdresult=no motion";
        if (strncmp(instr, noMotionString, strlen(noMotionString)) != 0) {
          syslog(LOG_WARNING, "[%s] Motion detected\n", ip);
          struct timeval current_capture;
          gettimeofday(&current_capture, NULL);
          double diff = difference_of_times(&current_capture, last_capture);
          if (diff >= 1.0) {
            size_t len = 0;
            struct timeval start_capture;
            gettimeofday(&start_capture, NULL);
            char *snapshotHTTP = captureSnapshot(ip, &len);
            struct timeval end_capture;
            gettimeofday(&end_capture, NULL);
            if (snapshotHTTP) {
              char *snapshot = startOfDataForHTTPRequest(snapshotHTTP);
              syslog(LOG_WARNING,
                     "[%s] Captured image of size %zu bytes in %f\n", ip, len,
                     difference_of_times(&end_capture, &start_capture));
              char *filePath = pathForImage();
              syslog(LOG_WARNING, "[%s] Saving to path %s\n", ip, filePath);
              FILE *file = fopen(filePath, "w");
              fwrite(snapshot, sizeof(char), len, file);
              fclose(file);
              free(snapshotHTTP);
              size_t filePathLen = strlen(filePath);
              filePath[filePathLen - 3] = 'm';
              filePath[filePathLen - 2] = 'o';
              filePath[filePathLen - 1] = 't';
              syslog(LOG_WARNING, "[%s] Saving motion data to %s\n", ip,
                     filePath);
              file = fopen(filePath, "w");
              fwrite(instr, sizeof(char), strlen(instr), file);
              fclose(file);
              free(filePath);
              gettimeofday(last_capture, NULL);
            } else {
              syslog(LOG_WARNING, "[%s] Error capturing image.\n", ip);
            }
          }
        }
      }
    }
    free(foo);
  }
}


x86 assembly (clang, -O0):
<check_camera>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <check_for_motion@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     14da <check_camera+0x2fa>
mov    -0x18(%rbp),%rdi
call   10f0 <startOfDataForHTTPRequest@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     14d1 <check_camera+0x2f1>
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   1100 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     14cc <check_camera+0x2ec>
lea    0xdc9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    %rax,%rdx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     14c7 <check_camera+0x2e7>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   10c0 <syslog@plt>
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <gettimeofday@plt>
mov    -0x10(%rbp),%rsi
lea    -0x38(%rbp),%rdi
call   1060 <difference_of_times@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd2d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     14c2 <check_camera+0x2e2>
movq   $0x0,-0x48(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <gettimeofday@plt>
mov    -0x8(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   10a0 <captureSnapshot@plt>
mov    %rax,-0x58(%rbp)
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <gettimeofday@plt>
cmpq   $0x0,-0x58(%rbp)
je     14a2 <check_camera+0x2c2>
mov    -0x58(%rbp),%rdi
call   10f0 <startOfDataForHTTPRequest@plt>
mov    %rax,-0x68(%rbp)
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <difference_of_times@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
lea    0xcc6(%rip),%rsi
mov    $0x1,%al
call   10c0 <syslog@plt>
mov    $0x0,%al
call   1070 <pathForImage@plt>
mov    %rax,-0x70(%rbp)
mov    0x2c5a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   10c0 <syslog@plt>
mov    -0x70(%rbp),%rdi
lea    0xccf(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
mov    -0x78(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x70(%rbp),%rdi
call   1090 <strlen@plt>
mov    %rax,-0x80(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
sub    $0x3,%rcx
movb   $0x6d,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
sub    $0x2,%rcx
movb   $0x6f,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x74,(%rax,%rcx,1)
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xc4b(%rip),%rsi
mov    $0x0,%al
call   10c0 <syslog@plt>
mov    -0x70(%rbp),%rdi
lea    0xc37(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    %rax,%rdx
mov    -0x78(%rbp),%rcx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
mov    -0x78(%rbp),%rdi
call   1080 <fclose@plt>
mov    -0x70(%rbp),%rdi
call   1040 <free@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <gettimeofday@plt>
jmp    14bd <check_camera+0x2dd>
mov    0x2b3f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xbeb(%rip),%rsi
mov    $0x0,%al
call   10c0 <syslog@plt>
jmp    14c2 <check_camera+0x2e2>
jmp    14c7 <check_camera+0x2e7>
jmp    14cc <check_camera+0x2ec>
jmp    14d1 <check_camera+0x2f1>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_camera>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <check_for_motion@plt>
test   %rax,%rax
je     1403 <check_camera+0x223>
mov    %rax,%rbx
mov    %rax,%rdi
call   10f0 <startOfDataForHTTPRequest@plt>
test   %rax,%rax
je     13fb <check_camera+0x21b>
lea    0xdeb(%rip),%rsi
mov    %rax,%rdi
call   1100 <strstr@plt>
test   %rax,%rax
je     13fb <check_camera+0x21b>
mov    %rax,%r12
lea    0xdda(%rip),%rsi
mov    $0x12,%edx
mov    %rax,%rdi
call   1050 <strncmp@plt>
test   %rax,%rax
je     13fb <check_camera+0x21b>
mov    0x2d93(%rip),%r13
mov    0x0(%r13),%edi
lea    0xdc5(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <syslog@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <difference_of_times@plt>
ucomisd 0xd74(%rip),%xmm0
jb     13fb <check_camera+0x21b>
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
lea    0x10(%rsp),%rsi
mov    %r15,%rdi
call   10a0 <captureSnapshot@plt>
mov    %rax,%rbp
mov    %rsp,%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
test   %rbp,%rbp
je     13e6 <check_camera+0x206>
mov    %rbp,%rdi
call   10f0 <startOfDataForHTTPRequest@plt>
mov    %rax,0x20(%rsp)
mov    %rbp,0x28(%rsp)
mov    0x0(%r13),%ebp
mov    0x10(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1060 <difference_of_times@plt>
lea    0xd3d(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    0x18(%rsp),%rcx
mov    $0x1,%al
call   10c0 <syslog@plt>
xor    %eax,%eax
call   1070 <pathForImage@plt>
mov    %rax,%rbp
mov    0x0(%r13),%edi
lea    0xd44(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10c0 <syslog@plt>
lea    0xd48(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
mov    %rax,%r13
mov    0x10(%rsp),%rdx
mov    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    %rax,%rcx
call   10e0 <fwrite@plt>
mov    %r13,%rdi
call   1080 <fclose@plt>
mov    0x28(%rsp),%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1090 <strlen@plt>
movw   $0x6f6d,-0x3(%rax,%rbp,1)
movb   $0x74,-0x1(%rax,%rbp,1)
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   10c0 <syslog@plt>
mov    %rbp,%rdi
lea    0xcd9(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%r15
mov    %r12,%rdi
call   1090 <strlen@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r15,%rcx
call   10e0 <fwrite@plt>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
jmp    13fb <check_camera+0x21b>
mov    0x0(%r13),%edi
lea    0xcb0(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <syslog@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [10 x i8] c"mdresult=\00"
@.str.1 = [19 x i8] c"mdresult=no motion\00"
@LOG_WARNING = global i32 0
@.str.2 = [22 x i8] c"[%s] Motion detected\0A\00"
@.str.3 = [45 x i8] c"[%s] Captured image of size %zu bytes in %f\0A\00"
@.str.4 = [24 x i8] c"[%s] Saving to path %s\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [31 x i8] c"[%s] Saving motion data to %s\0A\00"
@.str.7 = [29 x i8] c"[%s] Error capturing image.\0A\00"
define void @check_camera(i8* %0, %struct.timeval* %1) {
%3 = alloca i8*
%4 = alloca %struct.timeval*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.timeval
%10 = alloca double
%11 = alloca i64
%12 = alloca %struct.timeval
%13 = alloca i8*
%14 = alloca %struct.timeval
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32*
%18 = alloca i64
store i8* %0, i8** %3
store %struct.timeval* %1, %struct.timeval** %4
%19 = load i8*, i8** %3
%20 = call i8* @check_for_motion(i8* %19)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %121
23: ; preds = %2
%24 = load i8*, i8** %5
%25 = call i8* @startOfDataForHTTPRequest(i8* %24)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %118
28: ; preds = %23
%29 = load i8*, i8** %6
%30 = call i8* @strstr(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %117
33: ; preds = %28
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %8
%34 = load i8*, i8** %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %8
%37 = call i64 @strlen(i8* %36)
%38 = call i64 @strncmp(i8* %34, i8* %35, i64 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %116
40: ; preds = %33
%41 = load i32, i32* @LOG_WARNING
%42 = load i8*, i8** %3
%43 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%45 = load %struct.timeval*, %struct.timeval** %4
%46 = call double @difference_of_times(%struct.timeval* %9, %struct.timeval* %45)
store double %46, double* %10
%47 = load double, double* %10
%48 = fcmp oge double %47, 1.000000e+00
br i1 %48, label %49, label %115
49: ; preds = %40
store i64 0, i64* %11
%50 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%51 = load i8*, i8** %3
%52 = call i8* @captureSnapshot(i8* %51, i64* %11)
store i8* %52, i8** %13
%53 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%54 = load i8*, i8** %13
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %110
56: ; preds = %49
%57 = load i8*, i8** %13
%58 = call i8* @startOfDataForHTTPRequest(i8* %57)
store i8* %58, i8** %15
%59 = load i32, i32* @LOG_WARNING
%60 = load i8*, i8** %3
%61 = load i64, i64* %11
%62 = call double @difference_of_times(%struct.timeval* %14, %struct.timeval* %12)
%63 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %59, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %60, i64 %61, double %62)
%64 = call i8* (...) @pathForImage()
store i8* %64, i8** %16
%65 = load i32, i32* @LOG_WARNING
%66 = load i8*, i8** %3
%67 = load i8*, i8** %16
%68 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %65, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %66, i8* %67)
%69 = load i8*, i8** %16
%70 = call i32* @fopen(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %70, i32** %17
%71 = load i8*, i8** %15
%72 = load i64, i64* %11
%73 = load i32*, i32** %17
%74 = call i32 @fwrite(i8* %71, i32 1, i64 %72, i32* %73)
%75 = load i32*, i32** %17
%76 = call i32 @fclose(i32* %75)
%77 = load i8*, i8** %13
%78 = call i32 @free(i8* %77)
%79 = load i8*, i8** %16
%80 = call i64 @strlen(i8* %79)
store i64 %80, i64* %18
%81 = load i8*, i8** %16
%82 = load i64, i64* %18
%83 = sub i64 %82, 3
%84 = getelementptr inbounds i8, i8* %81, i64 %83
store i8 109, i8* %84
%85 = load i8*, i8** %16
%86 = load i64, i64* %18
%87 = sub i64 %86, 2
%88 = getelementptr inbounds i8, i8* %85, i64 %87
store i8 111, i8* %88
%89 = load i8*, i8** %16
%90 = load i64, i64* %18
%91 = sub i64 %90, 1
%92 = getelementptr inbounds i8, i8* %89, i64 %91
store i8 116, i8* %92
%93 = load i32, i32* @LOG_WARNING
%94 = load i8*, i8** %3
%95 = load i8*, i8** %16
%96 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %93, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %94, i8* %95)
%97 = load i8*, i8** %16
%98 = call i32* @fopen(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %98, i32** %17
%99 = load i8*, i8** %7
%100 = load i8*, i8** %7
%101 = call i64 @strlen(i8* %100)
%102 = load i32*, i32** %17
%103 = call i32 @fwrite(i8* %99, i32 1, i64 %101, i32* %102)
%104 = load i32*, i32** %17
%105 = call i32 @fclose(i32* %104)
%106 = load i8*, i8** %16
%107 = call i32 @free(i8* %106)
%108 = load %struct.timeval*, %struct.timeval** %4
%109 = call i32 @gettimeofday(%struct.timeval* %108, i32* null)
br label %114
110: ; preds = %49
%111 = load i32, i32* @LOG_WARNING
%112 = load i8*, i8** %3
%113 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %111, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %110, %56
br label %115
115: ; preds = %114, %40
br label %116
116: ; preds = %115, %33
br label %117
117: ; preds = %116, %28
br label %118
118: ; preds = %117, %23
%119 = load i8*, i8** %5
%120 = call i32 @free(i8* %119)
br label %121
121: ; preds = %118, %2
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [10 x i8] c"mdresult=\00"
@.str.1 = [19 x i8] c"mdresult=no motion\00"
@LOG_WARNING = global i32 0
@.str.2 = [22 x i8] c"[%s] Motion detected\0A\00"
@.str.3 = [45 x i8] c"[%s] Captured image of size %zu bytes in %f\0A\00"
@.str.4 = [24 x i8] c"[%s] Saving to path %s\0A\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [31 x i8] c"[%s] Saving motion data to %s\0A\00"
@.str.7 = [29 x i8] c"[%s] Error capturing image.\0A\00"
define void @check_camera(i8* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval
%4 = alloca i64
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = tail call i8* @check_for_motion(i8* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %69, label %9
9: ; preds = %2
%10 = tail call i8* @startOfDataForHTTPRequest(i8* %7)
%11 = icmp eq i8* %10, null
br i1 %11, label %67, label %12
12: ; preds = %9
%13 = tail call i8* @strstr(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %67, label %15
15: ; preds = %12
%16 = tail call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i64 18)
%17 = icmp eq i64 %16, 0
br i1 %17, label %67, label %18
18: ; preds = %15
%19 = load i32, i32* @LOG_WARNING
%20 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%21 = bitcast %struct.timeval* %3 to i8*
%22 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%23 = call double @difference_of_times(%struct.timeval* %3, %struct.timeval* %1)
%24 = fcmp ult double %23, 1.000000e+00
br i1 %24, label %66, label %25
25: ; preds = %18
%26 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%27 = bitcast %struct.timeval* %5 to i8*
%28 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%29 = call i8* @captureSnapshot(i8* %0, i64* %4)
%30 = bitcast %struct.timeval* %6 to i8*
%31 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%32 = icmp eq i8* %29, null
br i1 %32, label %62, label %33
33: ; preds = %25
%34 = call i8* @startOfDataForHTTPRequest(i8* %29)
%35 = load i32, i32* @LOG_WARNING
%36 = load i64, i64* %4
%37 = call double @difference_of_times(%struct.timeval* %6, %struct.timeval* %5)
%38 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %0, i64 %36, double %37)
%39 = call i8* (...) @pathForImage()
%40 = load i32, i32* @LOG_WARNING
%41 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %40, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %39)
%42 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = load i64, i64* %4
%44 = call i32 @fwrite(i8* %34, i32 1, i64 %43, i32* %42)
%45 = call i32 @fclose(i32* %42)
%46 = call i32 @free(i8* %29)
%47 = call i64 @strlen(i8* dereferenceable(1) %39)
%48 = add i64 %47, -3
%49 = getelementptr inbounds i8, i8* %39, i64 %48
store i8 109, i8* %49
%50 = add i64 %47, -2
%51 = getelementptr inbounds i8, i8* %39, i64 %50
store i8 111, i8* %51
%52 = add i64 %47, -1
%53 = getelementptr inbounds i8, i8* %39, i64 %52
store i8 116, i8* %53
%54 = load i32, i32* @LOG_WARNING
%55 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %54, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %39)
%56 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%57 = call i64 @strlen(i8* %13)
%58 = call i32 @fwrite(i8* %13, i32 1, i64 %57, i32* %56)
%59 = call i32 @fclose(i32* %56)
%60 = call i32 @free(i8* %39)
%61 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %65
62: ; preds = %25
%63 = load i32, i32* @LOG_WARNING
%64 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %63, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %0)
br label %65
65: ; preds = %62, %33
br label %66
66: ; preds = %65, %18
br label %67
67: ; preds = %12, %66, %15, %9
%68 = call i32 @free(i8* %7)
br label %69
69: ; preds = %67, %2
ret void
}