#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*/ printf(char *, ...);
void rgb_separate_out(void *ctxx, int idx, unsigned char r, unsigned char g,
                      unsigned char b) {
  int rgb = (int)ctxx;
  if ((idx % 16) == 0)
    printf("\t");
  switch (rgb) {
  case 0:
    printf("%3d,", r);
    break;
  case 1:
    printf("%3d,", g);
    break;
  case 2:
    printf("%3d,", b);
    break;
  }
  if ((idx % 16) == 15)
    printf("\n");
}


x86 assembly (clang, -O0):
<rgb_separate_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %dl,-0xd(%rbp)
mov    %cl,-0xe(%rbp)
mov    %al,-0xf(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1154 <rgb_separate_out+0x44>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1189 <rgb_separate_out+0x79>
jmp    1167 <rgb_separate_out+0x57>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     11a0 <rgb_separate_out+0x90>
jmp    1178 <rgb_separate_out+0x68>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     11b7 <rgb_separate_out+0xa7>
jmp    11c9 <rgb_separate_out+0xb9>
movzbl -0xd(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <rgb_separate_out+0xb9>
movzbl -0xe(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c9 <rgb_separate_out+0xb9>
movzbl -0xf(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11eb <rgb_separate_out+0xdb>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb_separate_out>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0xf(%rbx),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xfffffff0,%eax
sub    %eax,%ebx
je     116a <rgb_separate_out+0x4a>
test   %ebp,%ebp
je     1178 <rgb_separate_out+0x58>
cmp    $0x2,%ebp
je     117d <rgb_separate_out+0x5d>
cmp    $0x1,%ebp
je     1180 <rgb_separate_out+0x60>
cmp    $0xf,%ebx
jne    1197 <rgb_separate_out+0x77>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    $0x9,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jne    1149 <rgb_separate_out+0x29>
mov    %r12d,%r15d
jmp    1180 <rgb_separate_out+0x60>
mov    %r14d,%r15d
movzbl %r15b,%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xf,%ebx
je     1158 <rgb_separate_out+0x38>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
@.str.1 = [5 x i8] c"%3d,\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @rgb_separate_out(i8* %0, i32 %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8 %2, i8* %8
store i8 %3, i8* %9
store i8 %4, i8* %10
%12 = load i8*, i8** %6
%13 = ptrtoint i8* %12 to i32
store i32 %13, i32* %11
%14 = load i32, i32* %7
%15 = srem i32 %14, 16
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %5
%20 = load i32, i32* %11
switch i32 %20, label %33 [
i32 0, label %21
i32 1, label %25
i32 2, label %29
]
21: ; preds = %19
%22 = load i8, i8* %8
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %33
25: ; preds = %19
%26 = load i8, i8* %9
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %33
29: ; preds = %19
%30 = load i8, i8* %10
%31 = zext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %19, %29, %25, %21
%34 = load i32, i32* %7
%35 = srem i32 %34, 16
%36 = icmp eq i32 %35, 15
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%3d,\00"
define void @rgb_separate_out(i8* %0, i32 %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = ptrtoint i8* %0 to i64
%7 = trunc i64 %6 to i32
%8 = srem i32 %1, 16
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @putchar(i32 9)
br label %12
12: ; preds = %10, %5
switch i32 %7, label %19 [
i32 0, label %15
i32 1, label %13
i32 2, label %14
]
13: ; preds = %12
br label %15
14: ; preds = %12
br label %15
15: ; preds = %12, %13, %14
%16 = phi i8 [ %4, %14 ], [ %3, %13 ], [ %2, %12 ]
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %15, %12
%20 = icmp eq i32 %8, 15
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = tail call i32 @putchar(i32 10)
br label %23
23: ; preds = %21, %19
ret void
}