#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 */

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
float *iio_read_image_float_vec(char *, int *, int *, int *);
int /*<<< orphan*/ imprintf_2d(int /*<<< orphan*/, char *, float *, int, int,
                               int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main_imprintf(int c, char *v[]) {
  if (c != 2 && c != 3) {
    fprintf(stderr, "usage:\n\t%s format [image]\n", *v);
    return EXIT_FAILURE;
  }
  char *format = v[1];
  char *finame = c > 2 ? v[2] : "-";
  int w, h, pd;
  float *x = iio_read_image_float_vec(finame, &w, &h, &pd);
  imprintf_2d(stdout, format, x, w, h, pd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main_imprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1180 <main_imprintf+0x50>
cmpl   $0x3,-0x8(%rbp)
je     1180 <main_imprintf+0x50>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <main_imprintf+0xd5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11a7 <main_imprintf+0x77>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    11b7 <main_imprintf+0x87>
lea    0xe6d(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    11b7 <main_imprintf+0x87>
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1030 <iio_read_image_float_vec@plt>
mov    %rax,-0x38(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1050 <imprintf_2d@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_imprintf>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    114e <main_imprintf+0x1e>
mov    0x8(%rsi),%rbx
cmp    $0x3,%edi
jb     116f <main_imprintf+0x3f>
mov    0x10(%rsi),%rdi
jmp    1176 <main_imprintf+0x46>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe9f(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e6b(%rip),%rax
jmp    11b3 <main_imprintf+0x83>
lea    0xea5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1030 <iio_read_image_float_vec@plt>
mov    0x2e3f(%rip),%rcx
mov    (%rcx),%edi
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
mov    0x4(%rsp),%r9d
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <imprintf_2d@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage:\0A\09%s format [image]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"-\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main_imprintf(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %46
23: ; preds = %14, %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
br label %34
33: ; preds = %23
br label %34
34: ; preds = %33, %29
%35 = phi i8* [ %32, %29 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %33 ]
store i8* %35, i8** %7
%36 = load i8*, i8** %7
%37 = call float* @iio_read_image_float_vec(i8* %36, i32* %8, i32* %9, i32* %10)
store float* %37, float** %11
%38 = load i32, i32* @stdout
%39 = load i8*, i8** %6
%40 = load float*, float** %11
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = call i32 @imprintf_2d(i32 %38, i8* %39, float* %40, i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* @EXIT_SUCCESS
store i32 %45, i32* %3
br label %46
46: ; preds = %34, %17
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage:\0A\09%s format [image]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"-\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main_imprintf(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = and i32 %0, -2
%7 = icmp eq i32 %6, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
br label %32
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = icmp ugt i32 %0, 2
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
br label %20
20: ; preds = %13, %17
%21 = phi i8* [ %19, %17 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %13 ]
%22 = bitcast i32* %3 to i8*
%23 = bitcast i32* %4 to i8*
%24 = bitcast i32* %5 to i8*
%25 = call float* @iio_read_image_float_vec(i8* %21, i32* %3, i32* %4, i32* %5)
%26 = load i32, i32* @stdout
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @imprintf_2d(i32 %26, i8* %15, float* %25, i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* @EXIT_SUCCESS
br label %32
32: ; preds = %20, %8
%33 = phi i32 [ %12, %8 ], [ %31, %20 ]
ret i32 %33
}