#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 *, ...);
int read_adc(int, int);
void output_adcs(int chip_select, int channel, int *sent) {
  if (chip_select == -1) {
    output_adcs(0, channel, sent);
    chip_select = 1;
  }
  if (channel == -1) {
    output_adcs(chip_select, 0, sent);
    channel = 1;
  }
  if (*sent == 1)
    printf(",");
  printf("%d", read_adc(chip_select, channel));
  *sent = 1;
}


x86 assembly (clang, -O0):
<output_adcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1161 <output_adcs+0x31>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
xor    %edi,%edi
call   1050 <output_adcs@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1180 <output_adcs+0x50>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
xor    %esi,%esi
call   1050 <output_adcs@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jne    119b <output_adcs+0x6b>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <read_adc@plt>
mov    %eax,%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_adcs>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
cmp    $0xffffffff,%edi
je     118a <output_adcs+0x4a>
cmp    $0xffffffff,%ebp
je     11a0 <output_adcs+0x60>
cmpl   $0x1,(%r14)
jne    1165 <output_adcs+0x25>
mov    $0x2c,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <read_adc@plt>
lea    0xe8b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x1,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
mov    %ebp,%esi
mov    %r14,%rdx
call   1060 <output_adcs@plt>
mov    $0x1,%ebx
cmp    $0xffffffff,%ebp
jne    1155 <output_adcs+0x15>
mov    %ebx,%edi
xor    %esi,%esi
mov    %r14,%rdx
call   1060 <output_adcs@plt>
mov    $0x1,%ebp
cmpl   $0x1,(%r14)
je     115b <output_adcs+0x1b>
jmp    1165 <output_adcs+0x25>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
define void @output_adcs(i32 %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %0, -1
br i1 %4, label %5, label %6
5: ; preds = %3
tail call void @output_adcs(i32 0, i32 %1, i32* %2)
br label %6
6: ; preds = %5, %3
%7 = phi i32 [ 1, %5 ], [ %0, %3 ]
%8 = icmp eq i32 %1, -1
br i1 %8, label %9, label %10
9: ; preds = %6
tail call void @output_adcs(i32 %7, i32 0, i32* %2)
br label %10
10: ; preds = %9, %6
%11 = phi i32 [ 1, %9 ], [ %1, %6 ]
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @putchar(i32 44)
br label %16
16: ; preds = %14, %10
%17 = tail call i32 @read_adc(i32 %7, i32 %11)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 1, i32* %2
ret void
}