#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*/ exif_cmd;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
void read_white_balance(const char *filename, float *red_balance,
                        float *blue_balance) {
  char exif_cmd[1000];
  int error = 0;
  int mode;
  int wb_r, wb_g1, wb_g2, wb_b;
  int raw_r, raw_g1, raw_g2, raw_b;
  snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -WhiteBalance -b \"%s\"",
           filename);
  FILE *exif_file = popen(exif_cmd, "r");
  if (exif_file) {
    if (fscanf(exif_file, "%d", &mode) != 1)
      error = 1;
    pclose(exif_file);
  } else
    error = 1;
  if (error)
    goto err;
  if (mode != 0) {
    snprintf(exif_cmd, sizeof(exif_cmd),
             "exiftool -WB_RGGBLevelsAsShot -b \"%s\"", filename);
  } else {
    snprintf(exif_cmd, sizeof(exif_cmd),
             "exiftool -WB_RGGBLevelsMeasured -b \"%s\"", filename);
  }
  exif_file = popen(exif_cmd, "r");
  if (exif_file) {
    if (fscanf(exif_file, "%d %d %d %d", &wb_r, &wb_g1, &wb_g2, &wb_b) != 4)
      error = 1;
    else {
      if ((mode != 0) || (wb_g1 - wb_g2 > wb_g2 / 2) ||
          (wb_g2 - wb_g1 > wb_g1 / 2)) {
        printf("White balance   : from %s\n",
               mode != 0 ? "WB_RGGBLevelsAsShot" : "WB_RGGBLevelsMeasured");
        *red_balance = ((float)wb_r) / wb_g1;
        *blue_balance = ((float)wb_b) / wb_g2;
      } else {
        snprintf(exif_cmd, sizeof(exif_cmd),
                 "exiftool -RawMeasuredRGGB -b \"%s\"", filename);
        FILE *exif_file2 = popen(exif_cmd, "r");
        if (exif_file2) {
          if (fscanf(exif_file2, "%d %d %d %d", &raw_r, &raw_g1, &raw_g2,
                     &raw_b) != 4)
            error = 1;
          else {
            printf("White balance   : from RawMeasuredRGGB\n");
            *red_balance = ((float)raw_g1) / raw_r;
            *blue_balance = ((float)raw_g2) / raw_b;
          }
          pclose(exif_file2);
        }
      }
    }
    pclose(exif_file);
  } else
    error = 1;
err:
  if (error)
    printf("**WARNING** could not extract white balance information, exiftool "
           "may need to be updated\n");
}


x86 assembly (clang, -O0):
<read_white_balance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x404(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xe78(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     11f5 <read_white_balance+0xa5>
mov    -0x430(%rbp),%rdi
lea    0xeb5(%rip),%rsi
lea    -0x408(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
cmp    $0x1,%eax
je     11e4 <read_white_balance+0x94>
movl   $0x1,-0x404(%rbp)
mov    -0x430(%rbp),%rdi
call   1040 <pclose@plt>
jmp    11ff <read_white_balance+0xaf>
movl   $0x1,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
je     1211 <read_white_balance+0xc1>
jmp    14a8 <read_white_balance+0x358>
cmpl   $0x0,-0x408(%rbp)
je     123f <read_white_balance+0xef>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xdec(%rip),%rdx
call   1050 <snprintf@plt>
jmp    125b <read_white_balance+0x10b>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xdf1(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     1499 <read_white_balance+0x349>
mov    -0x430(%rbp),%rdi
lea    0xdde(%rip),%rsi
lea    -0x40c(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    -0x414(%rbp),%r8
lea    -0x418(%rbp),%r9
mov    $0x0,%al
call   1060 <fscanf@plt>
cmp    $0x4,%eax
je     12cc <read_white_balance+0x17c>
movl   $0x1,-0x404(%rbp)
jmp    1488 <read_white_balance+0x338>
cmpl   $0x0,-0x408(%rbp)
jne    1339 <read_white_balance+0x1e9>
mov    -0x410(%rbp),%eax
sub    -0x414(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x414(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x43c(%rbp),%eax
cmp    %ecx,%eax
jg     1339 <read_white_balance+0x1e9>
mov    -0x414(%rbp),%eax
sub    -0x410(%rbp),%eax
mov    %eax,-0x440(%rbp)
mov    -0x410(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x440(%rbp),%eax
cmp    %ecx,%eax
jle    139f <read_white_balance+0x24f>
mov    -0x408(%rbp),%ecx
lea    0xd64(%rip),%rsi
lea    0xd49(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x40c(%rbp),%xmm0
ff
cvtsi2ssl -0x410(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
cvtsi2ssl -0x418(%rbp),%xmm0
ff
cvtsi2ssl -0x414(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
jmp    1483 <read_white_balance+0x333>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xd0a(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xc56(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     147e <read_white_balance+0x32e>
mov    -0x438(%rbp),%rdi
lea    0xc7e(%rip),%rsi
lea    -0x41c(%rbp),%rdx
lea    -0x420(%rbp),%rcx
lea    -0x424(%rbp),%r8
lea    -0x428(%rbp),%r9
mov    $0x0,%al
call   1060 <fscanf@plt>
cmp    $0x4,%eax
je     142c <read_white_balance+0x2dc>
movl   $0x1,-0x404(%rbp)
jmp    1472 <read_white_balance+0x322>
lea    0xcaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2ssl -0x420(%rbp),%xmm0
ff
cvtsi2ssl -0x41c(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
cvtsi2ssl -0x424(%rbp),%xmm0
ff
cvtsi2ssl -0x428(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x438(%rbp),%rdi
call   1040 <pclose@plt>
jmp    1483 <read_white_balance+0x333>
jmp    1488 <read_white_balance+0x338>
mov    -0x430(%rbp),%rdi
call   1040 <pclose@plt>
jmp    14a3 <read_white_balance+0x353>
movl   $0x1,-0x404(%rbp)
jmp    14a8 <read_white_balance+0x358>
cmpl   $0x0,-0x404(%rbp)
je     14c3 <read_white_balance+0x373>
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_white_balance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
lea    0xe7f(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r13,%rcx
call   1060 <snprintf@plt>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     138f <read_white_balance+0x22f>
mov    %rax,%rbx
lea    0xec0(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <pclose@plt>
cmp    $0x1,%ebp
jne    138f <read_white_balance+0x22f>
cmpl   $0x0,0x14(%rsp)
lea    0xe61(%rip),%rax
lea    0xe34(%rip),%rdx
cmove  %rax,%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r13,%rcx
call   1060 <snprintf@plt>
lea    0xe12(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     138f <read_white_balance+0x22f>
mov    %rax,%r12
lea    0xe47(%rip),%rsi
lea    0x2c(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x28(%rsp),%r9
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
cmp    $0x4,%eax
jne    1387 <read_white_balance+0x227>
cmpl   $0x0,0x14(%rsp)
je     125f <read_white_balance+0xff>
lea    0xe39(%rip),%rsi
jmp    128e <read_white_balance+0x12e>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%eax
mov    %ecx,%edx
sub    %eax,%edx
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
lea    0xe2f(%rip),%rsi
cmp    %edi,%edx
jg     128e <read_white_balance+0x12e>
sub    %ecx,%eax
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
cmp    %edx,%eax
jle    12d9 <read_white_balance+0x179>
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2ssl 0x2c(%rsp),%xmm0
cvtsi2ssl 0x10(%rsp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r15)
xorps  %xmm0,%xmm0
cvtsi2ssl 0x28(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0xc(%rsp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r14)
mov    %r12,%rdi
call   1050 <pclose@plt>
jmp    139b <read_white_balance+0x23b>
lea    0xde0(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r13,%rcx
call   1060 <snprintf@plt>
lea    0xd23(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     12cc <read_white_balance+0x16c>
mov    %rax,%rbx
lea    0xd5c(%rip),%rsi
lea    0x24(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
cmp    $0x4,%eax
jne    137f <read_white_balance+0x21f>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
cvtsi2ssl 0x20(%rsp),%xmm0
cvtsi2ssl 0x24(%rsp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r15)
xorps  %xmm0,%xmm0
cvtsi2ssl 0x1c(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x18(%rsp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r14)
mov    %rbx,%rdi
call   1050 <pclose@plt>
jmp    12cc <read_white_balance+0x16c>
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %r12,%rdi
call   1050 <pclose@plt>
lea    0xd4c(%rip),%rdi
call   1030 <puts@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"exiftool -WhiteBalance -b \22%s\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"exiftool -WB_RGGBLevelsAsShot -b \22%s\22\00"
@.str.4 = [40 x i8] c"exiftool -WB_RGGBLevelsMeasured -b \22%s\22\00"
@.str.5 = [12 x i8] c"%d %d %d %d\00"
@.str.6 = [27 x i8] c"White balance : from %s\0A\00"
@.str.7 = [20 x i8] c"WB_RGGBLevelsAsShot\00"
@.str.8 = [22 x i8] c"WB_RGGBLevelsMeasured\00"
@.str.9 = [34 x i8] c"exiftool -RawMeasuredRGGB -b \22%s\22\00"
@.str.10 = [40 x i8] c"White balance : from RawMeasuredRGGB\0A\00"
@.str.11 = [90 x i8] c"**WARNING** could not extract white balance information, exiftool may need to be updated\0A\00"
define void @read_white_balance(i8* %0, float* %1, float* %2) {
%4 = alloca i8*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [1000 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
store i8* %0, i8** %4
store float* %1, float** %5
store float* %2, float** %6
store i32 0, i32* %8
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%21 = load i8*, i8** %4
%22 = call i32 @snprintf(i8* %20, i32 1000, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%24 = call i32* @popen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %18
%25 = load i32*, i32** %18
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %35
27: ; preds = %3
%28 = load i32*, i32** %18
%29 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%30 = icmp ne i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %8
br label %32
32: ; preds = %31, %27
%33 = load i32*, i32** %18
%34 = call i32 @pclose(i32* %33)
br label %36
35: ; preds = %3
store i32 1, i32* %8
br label %36
36: ; preds = %35, %32
%37 = load i32, i32* %8
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36
br label %133
40: ; preds = %36
%41 = load i32, i32* %9
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = call i32 @snprintf(i8* %44, i32 1000, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %51
47: ; preds = %40
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%49 = load i8*, i8** %4
%50 = call i32 @snprintf(i8* %48, i32 1000, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %43
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%53 = call i32* @popen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %53, i32** %18
%54 = load i32*, i32** %18
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %131
56: ; preds = %51
%57 = load i32*, i32** %18
%58 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %57, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
%59 = icmp ne i32 %58, 4
br i1 %59, label %60, label %61
60: ; preds = %56
store i32 1, i32* %8
br label %128
61: ; preds = %56
%62 = load i32, i32* %9
%63 = icmp ne i32 %62, 0
br i1 %63, label %78, label %64
64: ; preds = %61
%65 = load i32, i32* %11
%66 = load i32, i32* %12
%67 = sub nsw i32 %65, %66
%68 = load i32, i32* %12
%69 = sdiv i32 %68, 2
%70 = icmp sgt i32 %67, %69
br i1 %70, label %78, label %71
71: ; preds = %64
%72 = load i32, i32* %12
%73 = load i32, i32* %11
%74 = sub nsw i32 %72, %73
%75 = load i32, i32* %11
%76 = sdiv i32 %75, 2
%77 = icmp sgt i32 %74, %76
br i1 %77, label %78, label %96
78: ; preds = %71, %64, %61
%79 = load i32, i32* %9
%80 = icmp ne i32 %79, 0
%81 = zext i1 %80 to i64
%82 = select i1 %80, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %82)
%84 = load i32, i32* %10
%85 = sitofp i32 %84 to float
%86 = load i32, i32* %11
%87 = sitofp i32 %86 to float
%88 = fdiv float %85, %87
%89 = load float*, float** %5
store float %88, float* %89
%90 = load i32, i32* %13
%91 = sitofp i32 %90 to float
%92 = load i32, i32* %12
%93 = sitofp i32 %92 to float
%94 = fdiv float %91, %93
%95 = load float*, float** %6
store float %94, float* %95
br label %127
96: ; preds = %71
%97 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%98 = load i8*, i8** %4
%99 = call i32 @snprintf(i8* %97, i32 1000, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %98)
%100 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%101 = call i32* @popen(i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %101, i32** %19
%102 = load i32*, i32** %19
%103 = icmp ne i32* %102, null
br i1 %103, label %104, label %126
104: ; preds = %96
%105 = load i32*, i32** %19
%106 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %105, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %14, i32* %15, i32* %16, i32* %17)
%107 = icmp ne i32 %106, 4
br i1 %107, label %108, label %109
108: ; preds = %104
store i32 1, i32* %8
br label %123
109: ; preds = %104
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%111 = load i32, i32* %15
%112 = sitofp i32 %111 to float
%113 = load i32, i32* %14
%114 = sitofp i32 %113 to float
%115 = fdiv float %112, %114
%116 = load float*, float** %5
store float %115, float* %116
%117 = load i32, i32* %16
%118 = sitofp i32 %117 to float
%119 = load i32, i32* %17
%120 = sitofp i32 %119 to float
%121 = fdiv float %118, %120
%122 = load float*, float** %6
store float %121, float* %122
br label %123
123: ; preds = %109, %108
%124 = load i32*, i32** %19
%125 = call i32 @pclose(i32* %124)
br label %126
126: ; preds = %123, %96
br label %127
127: ; preds = %126, %78
br label %128
128: ; preds = %127, %60
%129 = load i32*, i32** %18
%130 = call i32 @pclose(i32* %129)
br label %132
131: ; preds = %51
store i32 1, i32* %8
br label %132
132: ; preds = %131, %128
br label %133
133: ; preds = %132, %39
%134 = load i32, i32* %8
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %133
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.11, i64 0, i64 0))
br label %138
138: ; preds = %136, %133
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"exiftool -WhiteBalance -b \22%s\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [38 x i8] c"exiftool -WB_RGGBLevelsAsShot -b \22%s\22\00"
@.str.4 = [40 x i8] c"exiftool -WB_RGGBLevelsMeasured -b \22%s\22\00"
@.str.5 = [12 x i8] c"%d %d %d %d\00"
@.str.6 = [27 x i8] c"White balance : from %s\0A\00"
@.str.7 = [20 x i8] c"WB_RGGBLevelsAsShot\00"
@.str.8 = [22 x i8] c"WB_RGGBLevelsMeasured\00"
@.str.9 = [34 x i8] c"exiftool -RawMeasuredRGGB -b \22%s\22\00"
@str = [89 x i8] c"**WARNING** could not extract white balance information, exiftool may need to be updated\00"
@str.12 = [39 x i8] c"White balance : from RawMeasuredRGGB\00"
define void @read_white_balance(i8* %0, float* nocapture writeonly %1, float* nocapture writeonly %2) {
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%15 = bitcast i32* %5 to i8*
%16 = bitcast i32* %6 to i8*
%17 = bitcast i32* %7 to i8*
%18 = bitcast i32* %8 to i8*
%19 = bitcast i32* %9 to i8*
%20 = bitcast i32* %10 to i8*
%21 = bitcast i32* %11 to i8*
%22 = bitcast i32* %12 to i8*
%23 = bitcast i32* %13 to i8*
%24 = call i32 @snprintf(i8* %14, i32 1000, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%25 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %94, label %27
27: ; preds = %3
%28 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%29 = icmp eq i32 %28, 1
%30 = call i32 @pclose(i32* %25)
br i1 %29, label %31, label %94
31: ; preds = %27
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0)
%35 = call i32 @snprintf(i8* %14, i32 1000, i8* %34, i8* %0)
%36 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %94, label %38
38: ; preds = %31
%39 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %6, i32* %7, i32* %8, i32* %9)
%40 = icmp eq i32 %39, 4
br i1 %40, label %41, label %92
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %54
44: ; preds = %41
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = sub nsw i32 %45, %46
%48 = sdiv i32 %46, 2
%49 = icmp sgt i32 %47, %48
br i1 %49, label %54, label %50
50: ; preds = %44
%51 = sub nsw i32 %46, %45
%52 = sdiv i32 %45, 2
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %67
54: ; preds = %50, %44, %41
%55 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %50 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %44 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), %41 ]
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = load i32, i32* %6
%58 = sitofp i32 %57 to float
%59 = load i32, i32* %7
%60 = sitofp i32 %59 to float
%61 = fdiv float %58, %60
store float %61, float* %1
%62 = load i32, i32* %9
%63 = sitofp i32 %62 to float
%64 = load i32, i32* %8
%65 = sitofp i32 %64 to float
%66 = fdiv float %63, %65
store float %66, float* %2
br label %88
67: ; preds = %50
%68 = call i32 @snprintf(i8* %14, i32 1000, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%69 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%70 = icmp eq i32* %69, null
br i1 %70, label %88, label %71
71: ; preds = %67
%72 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
%73 = icmp eq i32 %72, 4
br i1 %73, label %74, label %90
74: ; preds = %71
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.12, i64 0, i64 0))
%76 = load i32, i32* %11
%77 = sitofp i32 %76 to float
%78 = load i32, i32* %10
%79 = sitofp i32 %78 to float
%80 = fdiv float %77, %79
store float %80, float* %1
%81 = load i32, i32* %12
%82 = sitofp i32 %81 to float
%83 = load i32, i32* %13
%84 = sitofp i32 %83 to float
%85 = fdiv float %82, %84
store float %85, float* %2
%86 = call i32 @pclose(i32* %69)
%87 = call i32 @pclose(i32* %36)
br label %96
88: ; preds = %54, %67
%89 = call i32 @pclose(i32* %36)
br label %96
90: ; preds = %71
%91 = call i32 @pclose(i32* %69)
br label %92
92: ; preds = %38, %90
%93 = call i32 @pclose(i32* %36)
br label %94
94: ; preds = %92, %3, %27, %31
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @str, i64 0, i64 0))
br label %96
96: ; preds = %74, %88, %94
ret void
}