#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 */
typedef unsigned int uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_led_set(FILE *fp, uint8_t led) {
  int i, first = 1;
  fprintf(fp, "{");
  for (i = 0; i < 4; i++)
    if (led & (1U << (i))) {
      if (!first)
        fprintf(fp, ",");
      fprintf(fp, "%d", i);
      first = 0;
    }
  fprintf(fp, "}");
}


x86 assembly (clang, -O0):
<print_led_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11ae <print_led_set+0x9e>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     119b <print_led_set+0x8b>
cmpl   $0x0,-0x14(%rbp)
jne    117f <print_led_set+0x6f>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
jmp    11a0 <print_led_set+0x90>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <print_led_set+0x2f>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_led_set>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x7b,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   $0x1,%bpl
jne    1156 <print_led_set+0x36>
test   $0x2,%bpl
jne    118a <print_led_set+0x6a>
test   $0x4,%bpl
jne    11b3 <print_led_set+0x93>
test   $0x8,%bpl
jne    11dc <print_led_set+0xbc>
jmp    11f2 <print_led_set+0xd2>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0x2,%bpl
jne    117d <print_led_set+0x5d>
test   $0x4,%bpl
jne    11a6 <print_led_set+0x86>
test   $0x8,%bpl
jne    11cf <print_led_set+0xaf>
jmp    11f2 <print_led_set+0xd2>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0x4,%bpl
je     1175 <print_led_set+0x55>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xe46(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0x8,%bpl
je     11f2 <print_led_set+0xd2>
mov    $0x2c,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x7d,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"{\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"}\00"
define void @print_led_set(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 1, i32* %6
%7 = load i32*, i32** %3
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %9
9: ; preds = %29, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %32
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = shl i32 1, %14
%16 = and i32 %13, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32*, i32** %3
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
%25 = load i32*, i32** %3
%26 = load i32, i32* %5
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i32 0, i32* %6
br label %28
28: ; preds = %24, %12
br label %29
29: ; preds = %28
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %9
32: ; preds = %9
%33 = load i32*, i32** %3
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
define void @print_led_set(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @fputc(i32 123, i32* %0)
%4 = and i32 %1, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = and i32 %1, 2
%8 = icmp eq i32 %7, 0
br i1 %8, label %20, label %15
9: ; preds = %2
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
%11 = and i32 %1, 2
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = tail call i32 @fputc(i32 44, i32* %0)
br label %15
15: ; preds = %6, %13
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %17
17: ; preds = %9, %15
%18 = and i32 %1, 4
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %23
20: ; preds = %6
%21 = and i32 %1, 4
%22 = icmp eq i32 %21, 0
br i1 %22, label %30, label %25
23: ; preds = %17
%24 = tail call i32 @fputc(i32 44, i32* %0)
br label %25
25: ; preds = %20, %23
%26 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %27
27: ; preds = %25, %17
%28 = and i32 %1, 8
%29 = icmp eq i32 %28, 0
br i1 %29, label %37, label %33
30: ; preds = %20
%31 = and i32 %1, 8
%32 = icmp eq i32 %31, 0
br i1 %32, label %37, label %35
33: ; preds = %27
%34 = tail call i32 @fputc(i32 44, i32* %0)
br label %35
35: ; preds = %30, %33
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %37
37: ; preds = %30, %35, %27
%38 = tail call i32 @fputc(i32 125, i32* %0)
ret void
}