void draw_cross(int x, int y, int length, int thickness, unsigned long color) {
  int i, j;
  printf("%s: at (%d,%d)\n", __FUNCTION__, x, y);
  for (j = 0; j < thickness; j++) {
    for (i = 0; i < length; i++) {
      put_pixel(x - (length - 1) / 2 + i, y - (thickness - 1) / 2 + j, color,
                0xFF);
    }
  }
  for (j = 0; j < thickness; j++) {
    for (i = 0; i < length; i++) {
      put_pixel(x - (thickness - 1) / 2 + j, y - (length - 1) / 2 + i, color,
                0xFF);
    }
  }
}


x86 assembly (clang, -O0):
<draw_cross>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xebb(%rip),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d6 <draw_cross+0xb6>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c3 <draw_cross+0xa3>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%edi
add    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
add    -0x20(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    $0xff,%ecx
mov    $0x0,%al
call   1040 <put_pixel@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <draw_cross+0x4d>
jmp    11c8 <draw_cross+0xa8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115a <draw_cross+0x3a>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1259 <draw_cross+0x139>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1246 <draw_cross+0x126>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%edi
add    -0x20(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
add    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    $0xff,%ecx
mov    $0x0,%al
call   1040 <put_pixel@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <draw_cross+0xd0>
jmp    124b <draw_cross+0x12b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11dd <draw_cross+0xbd>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_cross>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r13
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%ecx
mov    %edi,%edx
lea    0xebf(%rip),%rdi
lea    0xec8(%rip),%rsi
mov    %rdx,0x10(%rsp)
mov    %ecx,0xc(%rsp)
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,0x18(%rsp)
test   %ebx,%ebx
jle    125e <draw_cross+0x13e>
lea    -0x1(%r15),%eax
shr    $0x1f,%eax
mov    %rax,0x28(%rsp)
add    %r15d,%eax
add    $0xffffffff,%eax
sar    %eax
mov    0x10(%rsp),%rcx
sub    %eax,%ecx
mov    %ecx,0x24(%rsp)
mov    0x18(%rsp),%rax
lea    -0x1(%rax),%ecx
shr    %ecx
mov    0xc(%rsp),%eax
mov    %ecx,0x20(%rsp)
sub    %ecx,%eax
mov    %rax,0x30(%rsp)
xor    %ebx,%ebx
jmp    11b9 <draw_cross+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    0x18(%rsp),%ebx
je     11f0 <draw_cross+0xd0>
test   %r15d,%r15d
jle    11b0 <draw_cross+0x90>
mov    0x30(%rsp),%rax
lea    (%rax,%rbx,1),%ebp
mov    0x24(%rsp),%r12d
mov    %r15d,%r14d
xchg   %ax,%ax
mov    %r12d,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    $0xff,%ecx
xor    %eax,%eax
call   1040 <put_pixel@plt>
add    $0x1,%r12d
add    $0xffffffff,%r14d
jne    11d0 <draw_cross+0xb0>
jmp    11b0 <draw_cross+0x90>
cmpl   $0x0,0x18(%rsp)
jle    125e <draw_cross+0x13e>
mov    0x10(%rsp),%rax
sub    0x20(%rsp),%eax
mov    %rax,0x10(%rsp)
mov    0x28(%rsp),%rax
add    %r15d,%eax
add    $0xffffffff,%eax
sar    %eax
sub    %eax,0xc(%rsp)
xor    %r12d,%r12d
jmp    122b <draw_cross+0x10b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    0x18(%rsp),%r12d
je     125e <draw_cross+0x13e>
test   %r15d,%r15d
jle    1220 <draw_cross+0x100>
mov    0x10(%rsp),%rax
lea    (%rax,%r12,1),%r14d
mov    0xc(%rsp),%ebx
mov    %r15d,%ebp
mov    %r14d,%edi
mov    %ebx,%esi
mov    %r13,%rdx
mov    $0xff,%ecx
xor    %eax,%eax
call   1040 <put_pixel@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1240 <draw_cross+0x120>
jmp    1220 <draw_cross+0x100>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%s: at (%d,%d)\0A\00"
@__FUNCTION__.draw_cross = [11 x i8] c"draw_cross\00"
define void @draw_cross(i32 %0, i32 %1, i32 %2, i32 %3, i64 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64 %4, i64* %10
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.draw_cross, i64 0, i64 0), i32 %13, i32 %14)
store i32 0, i32* %12
br label %16
16: ; preds = %46, %5
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %49
20: ; preds = %16
store i32 0, i32* %11
br label %21
21: ; preds = %42, %20
%22 = load i32, i32* %11
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %45
25: ; preds = %21
%26 = load i32, i32* %6
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 1
%29 = sdiv i32 %28, 2
%30 = sub nsw i32 %26, %29
%31 = load i32, i32* %11
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = sub nsw i32 %34, 1
%36 = sdiv i32 %35, 2
%37 = sub nsw i32 %33, %36
%38 = load i32, i32* %12
%39 = add nsw i32 %37, %38
%40 = load i64, i64* %10
%41 = call i32 (i32, i32, i64, i32, ...) bitcast (i32 (...)* @put_pixel to i32 (i32, i32, i64, i32, ...)*)(i32 %32, i32 %39, i64 %40, i32 255)
br label %42
42: ; preds = %25
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %21
45: ; preds = %21
br label %46
46: ; preds = %45
%47 = load i32, i32* %12
%48 = add nsw i32 %47, 1
store i32 %48, i32* %12
br label %16
49: ; preds = %16
store i32 0, i32* %12
br label %50
50: ; preds = %80, %49
%51 = load i32, i32* %12
%52 = load i32, i32* %9
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %83
54: ; preds = %50
store i32 0, i32* %11
br label %55
55: ; preds = %76, %54
%56 = load i32, i32* %11
%57 = load i32, i32* %8
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %79
59: ; preds = %55
%60 = load i32, i32* %6
%61 = load i32, i32* %9
%62 = sub nsw i32 %61, 1
%63 = sdiv i32 %62, 2
%64 = sub nsw i32 %60, %63
%65 = load i32, i32* %12
%66 = add nsw i32 %64, %65
%67 = load i32, i32* %7
%68 = load i32, i32* %8
%69 = sub nsw i32 %68, 1
%70 = sdiv i32 %69, 2
%71 = sub nsw i32 %67, %70
%72 = load i32, i32* %11
%73 = add nsw i32 %71, %72
%74 = load i64, i64* %10
%75 = call i32 (i32, i32, i64, i32, ...) bitcast (i32 (...)* @put_pixel to i32 (i32, i32, i64, i32, ...)*)(i32 %66, i32 %73, i64 %74, i32 255)
br label %76
76: ; preds = %59
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 1
store i32 %78, i32* %11
br label %55
79: ; preds = %55
br label %80
80: ; preds = %79
%81 = load i32, i32* %12
%82 = add nsw i32 %81, 1
store i32 %82, i32* %12
br label %50
83: ; preds = %50
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"%s: at (%d,%d)\0A\00"
@__FUNCTION__.draw_cross = [11 x i8] c"draw_cross\00"
define void @draw_cross(i32 %0, i32 %1, i32 %2, i32 %3, i64 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.draw_cross, i64 0, i64 0), i32 %0, i32 %1)
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %51
8: ; preds = %5
%9 = icmp sgt i32 %2, 0
%10 = add nsw i32 %2, -1
%11 = sdiv i32 %10, -2
%12 = add i32 %11, %0
%13 = add nsw i32 %3, -1
%14 = lshr i32 %13, 1
%15 = sub i32 %1, %14
br label %16
16: ; preds = %8, %35
%17 = phi i32 [ 0, %8 ], [ %36, %35 ]
br i1 %9, label %18, label %35
18: ; preds = %16
%19 = add nsw i32 %15, %17
br label %29
20: ; preds = %35
br i1 %7, label %21, label %51
21: ; preds = %20
%22 = icmp sgt i32 %2, 0
%23 = add nsw i32 %3, -1
%24 = lshr i32 %23, 1
%25 = sub i32 %0, %24
%26 = add nsw i32 %2, -1
%27 = sdiv i32 %26, -2
%28 = add i32 %27, %1
br label %38
29: ; preds = %18, %29
%30 = phi i32 [ 0, %18 ], [ %33, %29 ]
%31 = add nsw i32 %12, %30
%32 = tail call i32 (i32, i32, i64, i32, ...) bitcast (i32 (...)* @put_pixel to i32 (i32, i32, i64, i32, ...)*)(i32 %31, i32 %19, i64 %4, i32 255)
%33 = add nuw nsw i32 %30, 1
%34 = icmp eq i32 %33, %2
br i1 %34, label %35, label %29
35: ; preds = %29, %16
%36 = add nuw nsw i32 %17, 1
%37 = icmp eq i32 %36, %3
br i1 %37, label %20, label %16
38: ; preds = %21, %48
%39 = phi i32 [ 0, %21 ], [ %49, %48 ]
br i1 %22, label %40, label %48
40: ; preds = %38
%41 = add nsw i32 %25, %39
br label %42
42: ; preds = %40, %42
%43 = phi i32 [ 0, %40 ], [ %46, %42 ]
%44 = add nsw i32 %28, %43
%45 = tail call i32 (i32, i32, i64, i32, ...) bitcast (i32 (...)* @put_pixel to i32 (i32, i32, i64, i32, ...)*)(i32 %41, i32 %44, i64 %4, i32 255)
%46 = add nuw nsw i32 %43, 1
%47 = icmp eq i32 %46, %2
br i1 %47, label %48, label %42
48: ; preds = %42, %38
%49 = add nuw nsw i32 %39, 1
%50 = icmp eq i32 %49, %3
br i1 %50, label %51, label %38
51: ; preds = %48, %5, %20
ret void
}