#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 /*<<< orphan*/ display_put(void *, unsigned int, unsigned int,
                               unsigned int);
void image_output(void *display_io, unsigned int *image) {
  unsigned int x, y, p, p1, p2, *img;
  img = image;
  for (y = 0; y < 480; y++) {
    for (x = 0; x < 640; x += 2) {
      p = *img;
      p2 = p & 0xffff;
      p1 = (p >> 16) & 0xffff;
      display_put(display_io, x, y, p1);
      display_put(display_io, x + 1, y, p2);
      img++;
    }
  }
}


x86 assembly (clang, -O0):
<image_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1e0,-0x18(%rbp)
jae    11c6 <image_output+0xb6>
movl   $0x0,-0x14(%rbp)
cmpl   $0x280,-0x14(%rbp)
jae    11b3 <image_output+0xa3>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
shr    $0x10,%eax
and    $0xffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <display_put@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1030 <display_put@plt>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <image_output+0x33>
jmp    11b8 <image_output+0xa8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112f <image_output+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<image_output>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%ecx
movzwl %cx,%r12d
shr    $0x10,%ecx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <display_put@plt>
lea    0x1(%rbp),%esi
mov    %r14,%rdi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <display_put@plt>
add    $0x4,%rbx
lea    0x2(%rbp),%eax
cmp    $0x27e,%ebp
mov    %eax,%ebp
jb     1140 <image_output+0x30>
add    $0x1,%r15d
cmp    $0x1e0,%r15d
jne    1130 <image_output+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @image_output(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%11 = load i32*, i32** %4
store i32* %11, i32** %10
store i32 0, i32* %6
br label %12
12: ; preds = %44, %2
%13 = load i32, i32* %6
%14 = icmp ult i32 %13, 480
br i1 %14, label %15, label %47
15: ; preds = %12
store i32 0, i32* %5
br label %16
16: ; preds = %40, %15
%17 = load i32, i32* %5
%18 = icmp ult i32 %17, 640
br i1 %18, label %19, label %43
19: ; preds = %16
%20 = load i32*, i32** %10
%21 = load i32, i32* %20
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = and i32 %22, 65535
store i32 %23, i32* %9
%24 = load i32, i32* %7
%25 = lshr i32 %24, 16
%26 = and i32 %25, 65535
store i32 %26, i32* %8
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = load i32, i32* %8
%31 = call i32 @display_put(i8* %27, i32 %28, i32 %29, i32 %30)
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = add i32 %33, 1
%35 = load i32, i32* %6
%36 = load i32, i32* %9
%37 = call i32 @display_put(i8* %32, i32 %34, i32 %35, i32 %36)
%38 = load i32*, i32** %10
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %10
br label %40
40: ; preds = %19
%41 = load i32, i32* %5
%42 = add i32 %41, 2
store i32 %42, i32* %5
br label %16
43: ; preds = %16
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add i32 %45, 1
store i32 %46, i32* %6
br label %12
47: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @image_output(i8* %0, i32* nocapture %1) {
br label %3
3: ; preds = %2, %18
%4 = phi i32* [ %1, %2 ], [ %15, %18 ]
%5 = phi i32 [ 0, %2 ], [ %19, %18 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32* [ %4, %3 ], [ %15, %6 ]
%8 = phi i32 [ 0, %3 ], [ %16, %6 ]
%9 = load i32, i32* %7
%10 = and i32 %9, 65535
%11 = lshr i32 %9, 16
%12 = tail call i32 @display_put(i8* %0, i32 %8, i32 %5, i32 %11)
%13 = or i32 %8, 1
%14 = tail call i32 @display_put(i8* %0, i32 %13, i32 %5, i32 %10)
%15 = getelementptr inbounds i32, i32* %7, i64 1
%16 = add nuw nsw i32 %8, 2
%17 = icmp ult i32 %8, 638
br i1 %17, label %6, label %18
18: ; preds = %6
%19 = add nuw nsw i32 %5, 1
%20 = icmp eq i32 %19, 480
br i1 %20, label %21, label %3
21: ; preds = %18
ret void
}