#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 *, char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int dng_has_original_raw(const char *dng_file) {
  char exif_cmd[1000];
  snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -OriginalRawFileData \"%s\"",
           dng_file);
  FILE *exif_file = popen(exif_cmd, "r");
  if (exif_file) {
    char ch;
    int has_original_raw = fscanf(exif_file, "%c", &ch) == 1;
    pclose(exif_file);
    return has_original_raw;
  }
  printf("%-16s: could not run exiftool\n", dng_file);
  return 0;
}


x86 assembly (clang, -O0):
<dng_has_original_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xe8a(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x408(%rbp)
cmpq   $0x0,-0x408(%rbp)
je     11e8 <dng_has_original_raw+0x98>
mov    -0x408(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x409(%rbp),%rdx
call   1060 <fscanf@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x410(%rbp)
mov    -0x408(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x410(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ff <dng_has_original_raw+0xaf>
mov    -0x10(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dng_has_original_raw>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
lea    0xe9b(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
lea    0xea2(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
test   %rax,%rax
je     11b8 <dng_has_original_raw+0x68>
mov    %rax,%rbx
lea    0xe8d(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
mov    %rbx,%rdi
call   1040 <pclose@plt>
jmp    11c9 <dng_has_original_raw+0x79>
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"exiftool -OriginalRawFileData \22%s\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [31 x i8] c"%-16s: could not run exiftool\0A\00"
define i32 @dng_has_original_raw(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1000 x i8]
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32
store i8* %0, i8** %3
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = call i32 @snprintf(i8* %8, i32 1000, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%12 = call i32* @popen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %23
15: ; preds = %1
%16 = load i32*, i32** %5
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
store i32 %19, i32* %7
%20 = load i32*, i32** %5
%21 = call i32 @pclose(i32* %20)
%22 = load i32, i32* %7
store i32 %22, i32* %2
br label %26
23: ; preds = %1
%24 = load i8*, i8** %3
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %24)
store i32 0, i32* %2
br label %26
26: ; preds = %23, %15
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@.str = [35 x i8] c"exiftool -OriginalRawFileData \22%s\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [31 x i8] c"%-16s: could not run exiftool\0A\00"
define i32 @dng_has_original_raw(i8* %0) {
%2 = alloca [1000 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 @snprintf(i8* %4, i32 1000, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32* @popen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = call i32 @pclose(i32* %6)
br label %15
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %13, %8
%16 = phi i32 [ %11, %8 ], [ 0, %13 ]
ret i32 %16
}