#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*/ get_color(int, int, int, int);
void draw_line(unsigned int *image_data, int width, int height, int y) {
  unsigned int *p = image_data + y * width;
  for (int x = 0; x < width; ++x) {
    *p++ = get_color(x, y, width, height);
  }
}


x86 assembly (clang, -O0):
<draw_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1183 <draw_line+0x73>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <get_color@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <draw_line+0x35>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    114b <draw_line+0x3b>
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %esi,%ebp
imul   %ecx,%esi
movslq %esi,%rax
lea    (%rdi,%rax,4),%r12
xor    %ebx,%ebx
mov    %ebx,%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <get_color@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1130 <draw_line+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @draw_line(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %8
%13 = load i32, i32* %6
%14 = mul nsw i32 %12, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %11, i64 %15
store i32* %16, i32** %9
store i32 0, i32* %10
br label %17
17: ; preds = %29, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = load i32, i32* %10
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @get_color(i32 %22, i32 %23, i32 %24, i32 %25)
%27 = load i32*, i32** %9
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %9
store i32 %26, i32* %27
br label %29
29: ; preds = %21
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
br label %17
32: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @draw_line(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = mul nsw i32 %3, %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
br label %11
10: ; preds = %11, %4
ret void
11: ; preds = %6, %11
%12 = phi i32 [ %16, %11 ], [ 0, %6 ]
%13 = phi i32* [ %15, %11 ], [ %9, %6 ]
%14 = tail call i32 @get_color(i32 %12, i32 %3, i32 %1, i32 %2)
%15 = getelementptr inbounds i32, i32* %13, i64 1
store i32 %14, i32* %13
%16 = add nuw nsw i32 %12, 1
%17 = icmp eq i32 %16, %1
br i1 %17, label %10, label %11
}