#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 (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 determined 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 determined 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;
  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,-0x408(%rbp)
je     122d <read_white_balance+0xdd>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xdfe(%rip),%rdx
call   1050 <snprintf@plt>
jmp    1249 <read_white_balance+0xf9>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xe03(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x430(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     1487 <read_white_balance+0x337>
mov    -0x430(%rbp),%rdi
lea    0xdf0(%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     12ba <read_white_balance+0x16a>
movl   $0x1,-0x404(%rbp)
jmp    1476 <read_white_balance+0x326>
cmpl   $0x0,-0x408(%rbp)
jne    1327 <read_white_balance+0x1d7>
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     1327 <read_white_balance+0x1d7>
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    138d <read_white_balance+0x23d>
mov    -0x408(%rbp),%ecx
lea    0xd7d(%rip),%rsi
lea    0xd62(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xd32(%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    1471 <read_white_balance+0x321>
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xd23(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xc68(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     146c <read_white_balance+0x31c>
mov    -0x438(%rbp),%rdi
lea    0xc90(%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     141a <read_white_balance+0x2ca>
movl   $0x1,-0x404(%rbp)
jmp    1460 <read_white_balance+0x310>
lea    0xcc8(%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    1471 <read_white_balance+0x321>
jmp    1476 <read_white_balance+0x326>
mov    -0x430(%rbp),%rdi
call   1040 <pclose@plt>
jmp    1491 <read_white_balance+0x341>
movl   $0x1,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
je     14ac <read_white_balance+0x35c>
lea    0xc73(%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     11e4 <read_white_balance+0x84>
mov    %rax,%rbx
lea    0xec4(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
setne  %bpl
mov    %rbx,%rdi
call   1050 <pclose@plt>
cmpl   $0x0,0x14(%rsp)
je     11e9 <read_white_balance+0x89>
lea    0xe3f(%rip),%rdx
jmp    11f0 <read_white_balance+0x90>
mov    $0x1,%ebp
lea    0xe57(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r13,%rcx
call   1060 <snprintf@plt>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     12dd <read_white_balance+0x17d>
mov    %rax,%r12
lea    0xe48(%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    125a <read_white_balance+0xfa>
cmpl   $0x0,0x14(%rsp)
je     1264 <read_white_balance+0x104>
lea    0xe45(%rip),%rsi
jmp    1293 <read_white_balance+0x133>
mov    %r12,%rdi
call   1050 <pclose@plt>
jmp    12dd <read_white_balance+0x17d>
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    0xe31(%rip),%rsi
cmp    %edi,%edx
jg     1293 <read_white_balance+0x133>
sub    %ecx,%eax
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
cmp    %edx,%eax
jle    12fb <read_white_balance+0x19b>
lea    0xde1(%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>
test   %ebp,%ebp
je     12e9 <read_white_balance+0x189>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc5(%rip),%rdx
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r13,%rcx
call   1060 <snprintf@plt>
lea    0xd01(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     12d1 <read_white_balance+0x171>
mov    %rax,%rbx
lea    0xd3a(%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>
mov    $0x1,%r13d
cmp    $0x4,%eax
jne    139d <read_white_balance+0x23d>
lea    0xddd(%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    %ebp,%r13d
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %r13d,%ebp
jmp    12d1 <read_white_balance+0x171>

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 = [34 x i8] c"White balance determined 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 = [47 x i8] c"White balance determined 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* %9
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%41 = load i8*, i8** %4
%42 = call i32 @snprintf(i8* %40, i32 1000, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %47
43: ; preds = %36
%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 ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %43, %39
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%49 = call i32* @popen(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %49, i32** %18
%50 = load i32*, i32** %18
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %127
52: ; preds = %47
%53 = load i32*, i32** %18
%54 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %53, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
%55 = icmp ne i32 %54, 4
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 1, i32* %8
br label %124
57: ; preds = %52
%58 = load i32, i32* %9
%59 = icmp ne i32 %58, 0
br i1 %59, label %74, label %60
60: ; preds = %57
%61 = load i32, i32* %11
%62 = load i32, i32* %12
%63 = sub nsw i32 %61, %62
%64 = load i32, i32* %12
%65 = sdiv i32 %64, 2
%66 = icmp sgt i32 %63, %65
br i1 %66, label %74, label %67
67: ; preds = %60
%68 = load i32, i32* %12
%69 = load i32, i32* %11
%70 = sub nsw i32 %68, %69
%71 = load i32, i32* %11
%72 = sdiv i32 %71, 2
%73 = icmp sgt i32 %70, %72
br i1 %73, label %74, label %92
74: ; preds = %67, %60, %57
%75 = load i32, i32* %9
%76 = icmp ne i32 %75, 0
%77 = zext i1 %76 to i64
%78 = select i1 %76, 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)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %78)
%80 = load i32, i32* %10
%81 = sitofp i32 %80 to float
%82 = load i32, i32* %11
%83 = sitofp i32 %82 to float
%84 = fdiv float %81, %83
%85 = load float*, float** %5
store float %84, float* %85
%86 = load i32, i32* %13
%87 = sitofp i32 %86 to float
%88 = load i32, i32* %12
%89 = sitofp i32 %88 to float
%90 = fdiv float %87, %89
%91 = load float*, float** %6
store float %90, float* %91
br label %123
92: ; preds = %67
%93 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%94 = load i8*, i8** %4
%95 = call i32 @snprintf(i8* %93, i32 1000, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %94)
%96 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%97 = call i32* @popen(i8* %96, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %97, i32** %19
%98 = load i32*, i32** %19
%99 = icmp ne i32* %98, null
br i1 %99, label %100, label %122
100: ; preds = %92
%101 = load i32*, i32** %19
%102 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %101, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %14, i32* %15, i32* %16, i32* %17)
%103 = icmp ne i32 %102, 4
br i1 %103, label %104, label %105
104: ; preds = %100
store i32 1, i32* %8
br label %119
105: ; preds = %100
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
%107 = load i32, i32* %15
%108 = sitofp i32 %107 to float
%109 = load i32, i32* %14
%110 = sitofp i32 %109 to float
%111 = fdiv float %108, %110
%112 = load float*, float** %5
store float %111, float* %112
%113 = load i32, i32* %16
%114 = sitofp i32 %113 to float
%115 = load i32, i32* %17
%116 = sitofp i32 %115 to float
%117 = fdiv float %114, %116
%118 = load float*, float** %6
store float %117, float* %118
br label %119
119: ; preds = %105, %104
%120 = load i32*, i32** %19
%121 = call i32 @pclose(i32* %120)
br label %122
122: ; preds = %119, %92
br label %123
123: ; preds = %122, %74
br label %124
124: ; preds = %123, %56
%125 = load i32*, i32** %18
%126 = call i32 @pclose(i32* %125)
br label %128
127: ; preds = %47
store i32 1, i32* %8
br label %128
128: ; preds = %127, %124
%129 = load i32, i32* %8
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.11, i64 0, i64 0))
br label %133
133: ; preds = %131, %128
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 = [34 x i8] c"White balance determined 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 = [46 x i8] c"White balance determined 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 %34, 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 ne i32 %28, 1
%30 = zext i1 %29 to i32
%31 = call i32 @pclose(i32* %25)
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %3, %27
%35 = phi i32 [ %30, %27 ], [ 1, %3 ]
br label %36
36: ; preds = %27, %34
%37 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), %34 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), %27 ]
%38 = phi i32 [ %35, %34 ], [ %30, %27 ]
%39 = call i32 @snprintf(i8* %14, i32 1000, i8* %37, i8* %0)
%40 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %99, label %42
42: ; preds = %36
%43 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %6, i32* %7, i32* %8, i32* %9)
%44 = icmp eq i32 %43, 4
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = call i32 @pclose(i32* %40)
br label %99
47: ; preds = %42
%48 = load i32, i32* %5
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = sub nsw i32 %51, %52
%54 = sdiv i32 %52, 2
%55 = icmp sgt i32 %53, %54
br i1 %55, label %60, label %56
56: ; preds = %50
%57 = sub nsw i32 %52, %51
%58 = sdiv i32 %51, 2
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %73
60: ; preds = %56, %50, %47
%61 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %56 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %50 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), %47 ]
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i8* %61)
%63 = load i32, i32* %6
%64 = sitofp i32 %63 to float
%65 = load i32, i32* %7
%66 = sitofp i32 %65 to float
%67 = fdiv float %64, %66
store float %67, float* %1
%68 = load i32, i32* %9
%69 = sitofp i32 %68 to float
%70 = load i32, i32* %8
%71 = sitofp i32 %70 to float
%72 = fdiv float %69, %71
store float %72, float* %2
br label %95
73: ; preds = %56
%74 = call i32 @snprintf(i8* %14, i32 1000, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%75 = call i32* @popen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%76 = icmp eq i32* %75, null
br i1 %76, label %95, label %77
77: ; preds = %73
%78 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %75, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
%79 = icmp eq i32 %78, 4
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.12, i64 0, i64 0))
%82 = load i32, i32* %11
%83 = sitofp i32 %82 to float
%84 = load i32, i32* %10
%85 = sitofp i32 %84 to float
%86 = fdiv float %83, %85
store float %86, float* %1
%87 = load i32, i32* %12
%88 = sitofp i32 %87 to float
%89 = load i32, i32* %13
%90 = sitofp i32 %89 to float
%91 = fdiv float %88, %90
store float %91, float* %2
br label %92
92: ; preds = %77, %80
%93 = phi i32 [ %38, %80 ], [ 1, %77 ]
%94 = call i32 @pclose(i32* %75)
br label %95
95: ; preds = %60, %92, %73
%96 = phi i32 [ %38, %60 ], [ %93, %92 ], [ %38, %73 ]
%97 = call i32 @pclose(i32* %40)
%98 = icmp eq i32 %96, 0
br i1 %98, label %101, label %99
99: ; preds = %36, %45, %95
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @str, i64 0, i64 0))
br label %101
101: ; preds = %99, %95
ret void
}