#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*/ adc_set_chan(int);
int /*<<< orphan*/ adc_start();
int /*<<< orphan*/ delay_ms(int);
int /*<<< orphan*/ gpio_a_analog(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void adc_test(void) {
  int i;
  gpio_a_analog(0);
  adc_set_chan(0);
  printf(" ADC channel 0\n");
  for (i = 0; i < 10; i++) {
    adc_start();
    delay_ms(1000);
  }
  printf(" temp\n");
  adc_set_chan(16);
  for (i = 0; i < 10; i++) {
    adc_start();
    delay_ms(1000);
  }
  printf(" vref\n");
  adc_set_chan(17);
  for (i = 0; i < 10; i++) {
    adc_start();
    delay_ms(1000);
  }
}


x86 assembly (clang, -O0):
<adc_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1030 <gpio_a_analog@plt>
xor    %edi,%edi
call   1040 <adc_set_chan@plt>
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11a2 <adc_test+0x52>
mov    $0x0,%al
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1179 <adc_test+0x29>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
mov    $0x10,%edi
call   1040 <adc_set_chan@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    11e8 <adc_test+0x98>
mov    $0x0,%al
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <adc_test+0x6f>
lea    0xe28(%rip),%rdi
call   1050 <printf@plt>
mov    $0x11,%edi
call   1040 <adc_set_chan@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    122e <adc_test+0xde>
mov    $0x0,%al
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <adc_test+0xb5>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adc_test>:
push   %rax
xor    %edi,%edi
call   1030 <gpio_a_analog@plt>
xor    %edi,%edi
call   1050 <adc_set_chan@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x10,%edi
call   1050 <adc_set_chan@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
lea    0xd39(%rip),%rdi
call   1040 <puts@plt>
mov    $0x11,%edi
call   1050 <adc_set_chan@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
call   1070 <delay_ms@plt>
xor    %eax,%eax
call   1060 <adc_start@plt>
mov    $0x3e8,%edi
pop    %rax
jmp    1070 <delay_ms@plt>

LLVM IR (-O0):
@.str = [16 x i8] c" ADC channel 0\0A\00"
@.str.1 = [7 x i8] c" temp\0A\00"
@.str.2 = [7 x i8] c" vref\0A\00"
define void @adc_test() {
%1 = alloca i32
%2 = call i32 @gpio_a_analog(i32 0)
%3 = call i32 @adc_set_chan(i32 0)
%4 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %5
5: ; preds = %11, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = call i32 (...) @adc_start()
%10 = call i32 @delay_ms(i32 1000)
br label %11
11: ; preds = %8
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %5
14: ; preds = %5
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @adc_set_chan(i32 16)
store i32 0, i32* %1
br label %17
17: ; preds = %23, %14
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = call i32 (...) @adc_start()
%22 = call i32 @delay_ms(i32 1000)
br label %23
23: ; preds = %20
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %17
26: ; preds = %17
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @adc_set_chan(i32 17)
store i32 0, i32* %1
br label %29
29: ; preds = %35, %26
%30 = load i32, i32* %1
%31 = icmp slt i32 %30, 10
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 (...) @adc_start()
%34 = call i32 @delay_ms(i32 1000)
br label %35
35: ; preds = %32
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %29
38: ; preds = %29
ret void
}

LLVM IR (-O2):
@str = [15 x i8] c" ADC channel 0\00"
@str.3 = [6 x i8] c" temp\00"
@str.4 = [6 x i8] c" vref\00"
define void @adc_test() {
%1 = tail call i32 @gpio_a_analog(i32 0)
%2 = tail call i32 @adc_set_chan(i32 0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @adc_start()
%5 = tail call i32 @delay_ms(i32 1000)
%6 = tail call i32 (...) @adc_start()
%7 = tail call i32 @delay_ms(i32 1000)
%8 = tail call i32 (...) @adc_start()
%9 = tail call i32 @delay_ms(i32 1000)
%10 = tail call i32 (...) @adc_start()
%11 = tail call i32 @delay_ms(i32 1000)
%12 = tail call i32 (...) @adc_start()
%13 = tail call i32 @delay_ms(i32 1000)
%14 = tail call i32 (...) @adc_start()
%15 = tail call i32 @delay_ms(i32 1000)
%16 = tail call i32 (...) @adc_start()
%17 = tail call i32 @delay_ms(i32 1000)
%18 = tail call i32 (...) @adc_start()
%19 = tail call i32 @delay_ms(i32 1000)
%20 = tail call i32 (...) @adc_start()
%21 = tail call i32 @delay_ms(i32 1000)
%22 = tail call i32 (...) @adc_start()
%23 = tail call i32 @delay_ms(i32 1000)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0))
%25 = tail call i32 @adc_set_chan(i32 16)
%26 = tail call i32 (...) @adc_start()
%27 = tail call i32 @delay_ms(i32 1000)
%28 = tail call i32 (...) @adc_start()
%29 = tail call i32 @delay_ms(i32 1000)
%30 = tail call i32 (...) @adc_start()
%31 = tail call i32 @delay_ms(i32 1000)
%32 = tail call i32 (...) @adc_start()
%33 = tail call i32 @delay_ms(i32 1000)
%34 = tail call i32 (...) @adc_start()
%35 = tail call i32 @delay_ms(i32 1000)
%36 = tail call i32 (...) @adc_start()
%37 = tail call i32 @delay_ms(i32 1000)
%38 = tail call i32 (...) @adc_start()
%39 = tail call i32 @delay_ms(i32 1000)
%40 = tail call i32 (...) @adc_start()
%41 = tail call i32 @delay_ms(i32 1000)
%42 = tail call i32 (...) @adc_start()
%43 = tail call i32 @delay_ms(i32 1000)
%44 = tail call i32 (...) @adc_start()
%45 = tail call i32 @delay_ms(i32 1000)
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
%47 = tail call i32 @adc_set_chan(i32 17)
%48 = tail call i32 (...) @adc_start()
%49 = tail call i32 @delay_ms(i32 1000)
%50 = tail call i32 (...) @adc_start()
%51 = tail call i32 @delay_ms(i32 1000)
%52 = tail call i32 (...) @adc_start()
%53 = tail call i32 @delay_ms(i32 1000)
%54 = tail call i32 (...) @adc_start()
%55 = tail call i32 @delay_ms(i32 1000)
%56 = tail call i32 (...) @adc_start()
%57 = tail call i32 @delay_ms(i32 1000)
%58 = tail call i32 (...) @adc_start()
%59 = tail call i32 @delay_ms(i32 1000)
%60 = tail call i32 (...) @adc_start()
%61 = tail call i32 @delay_ms(i32 1000)
%62 = tail call i32 (...) @adc_start()
%63 = tail call i32 @delay_ms(i32 1000)
%64 = tail call i32 (...) @adc_start()
%65 = tail call i32 @delay_ms(i32 1000)
%66 = tail call i32 (...) @adc_start()
%67 = tail call i32 @delay_ms(i32 1000)
ret void
}