#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;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char const *);
int system(char *);
int extract_original_raw(const char *dng_file, const char *raw_file) {
  printf("%-16s: extracting from %s\n", raw_file, dng_file);
  char exif_cmd[1000];
  snprintf(exif_cmd, sizeof(exif_cmd),
           "exiftool \"%s\" -OriginalRawFileData -b > \"%s\"", dng_file,
           raw_file);
  int r = system(exif_cmd);
  if (r != 0) {
    printf("%-16s: could not extract original raw\n", dng_file);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<extract_original_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x3e8,%esi
lea    0xea7(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x400(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
je     11b6 <extract_original_raw+0x86>
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bd <extract_original_raw+0x8d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_original_raw>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xeb6(%rip),%rdi
xor    %r14d,%r14d
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x3e8,%esi
mov    %rbx,%rcx
mov    %rbp,%r8
call   1050 <snprintf@plt>
mov    %r15,%rdi
call   1030 <system@plt>
test   %eax,%eax
je     1193 <extract_original_raw+0x63>
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1199 <extract_original_raw+0x69>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%-16s: extracting from %s\0A\00"
@.str.1 = [45 x i8] c"exiftool \22%s\22 -OriginalRawFileData -b > \22%s\22\00"
@.str.2 = [39 x i8] c"%-16s: could not extract original raw\0A\00"
define i32 @extract_original_raw(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1000 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = call i32 @snprintf(i8* %11, i32 1000, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %13)
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%16 = call i32 @system(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 0, i32* %3
br label %23
22: ; preds = %2
store i32 1, i32* %3
br label %23
23: ; preds = %22, %19
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [27 x i8] c"%-16s: extracting from %s\0A\00"
@.str.1 = [45 x i8] c"exiftool \22%s\22 -OriginalRawFileData -b > \22%s\22\00"
@.str.2 = [39 x i8] c"%-16s: could not extract original raw\0A\00"
define i32 @extract_original_raw(i8* %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 1000, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%7 = call i32 @system(i8* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %2, %9
%12 = phi i32 [ 0, %9 ], [ 1, %2 ]
ret i32 %12
}