int write_image_array(file_name, array)
char *file_name;
short **array;
{
  int ok = 0;
  if (is_a_tiff(file_name)) {
    write_tiff_image(file_name, array);
    ok = 1;
  }
  if (is_a_bmp(file_name)) {
    write_bmp_image(file_name, array);
    ok = 1;
  }
  if (ok == 0) {
    printf("\nERROR could not write file %s", file_name);
    exit(1);
  }
  return (1);
}


x86 assembly (clang, -O0):
<write_image_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <is_a_tiff@plt>
cmp    $0x0,%eax
je     11a1 <write_image_array+0x41>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <write_tiff_image@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <is_a_bmp@plt>
cmp    $0x0,%eax
je     11cb <write_image_array+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1070 <write_bmp_image@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11f1 <write_image_array+0x91>
mov    -0x8(%rbp),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_image_array>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1080 <is_a_tiff@plt>
mov    %rbx,%rdi
test   %eax,%eax
je     1192 <write_image_array+0x32>
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <write_tiff_image@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <is_a_bmp@plt>
test   %eax,%eax
jne    119d <write_image_array+0x3d>
jmp    11aa <write_image_array+0x4a>
xor    %eax,%eax
call   1050 <is_a_bmp@plt>
test   %eax,%eax
je     11b7 <write_image_array+0x57>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <write_bmp_image@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\0AERROR could not write file %s\00"
define i32 @write_image_array(i8* %0, i16** %1) {
%3 = alloca i8*
%4 = alloca i16**
%5 = alloca i32
store i8* %0, i8** %3
store i16** %1, i16*** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @is_a_tiff to i32 (i8*, ...)*)(i8* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = load i16**, i16*** %4
%12 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_tiff_image to i32 (i8*, i16**, ...)*)(i8* %10, i16** %11)
store i32 1, i32* %5
br label %13
13: ; preds = %9, %2
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @is_a_bmp to i32 (i8*, ...)*)(i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i16**, i16*** %4
%20 = call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_bmp_image to i32 (i8*, i16**, ...)*)(i8* %18, i16** %19)
store i32 1, i32* %5
br label %21
21: ; preds = %17, %13
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %25)
unreachable
27: ; preds = %21
ret i32 1
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0AERROR could not write file %s\00"
define i32 @write_image_array(i8* %0, i16** %1) {
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @is_a_tiff to i32 (i8*, ...)*)(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @is_a_bmp to i32 (i8*, ...)*)(i8* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %12
8: ; preds = %2
%9 = tail call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_tiff_image to i32 (i8*, i16**, ...)*)(i8* %0, i16** %1)
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @is_a_bmp to i32 (i8*, ...)*)(i8* %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8, %5
%13 = tail call i32 (i8*, i16**, ...) bitcast (i32 (...)* @write_bmp_image to i32 (i8*, i16**, ...)*)(i8* %0, i16** %1)
br label %16
14: ; preds = %5
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
tail call void @exit(i32 1)
unreachable
16: ; preds = %8, %12
ret i32 1
}