#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*/ delay_ms(int);
int /*<<< orphan*/ gpio_a_analog(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ relay_closed();
int /*<<< orphan*/ relay_open();
int /*<<< orphan*/ show_battery(int, int);
int /*<<< orphan*/ show_readings(int, int);
int /*<<< orphan*/ show_temp(int, int);
void adc_test1(void) {
  gpio_a_analog(0);
  printf(" ADC channel 0\n");
  adc_set_chan(0);
  relay_open();
  printf("Relay open\n");
  show_battery(5, 1000);
  relay_closed();
  printf("Relay closed\n");
  delay_ms(1000);
  show_battery(5, 1000);
  relay_open();
  printf("Relay open\n");
  delay_ms(1000);
  show_battery(5, 1000);
  printf(" temp\n");
  adc_set_chan(16);
  show_temp(5, 1000);
  printf(" vref\n");
  adc_set_chan(17);
  show_readings(5, 1000);
  printf(" ADC channel 0\n");
  adc_set_chan(0);
  show_battery(5, 1000);
}


x86 assembly (clang, -O0):
<adc_test1>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1030 <gpio_a_analog@plt>
lea    0xe5e(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1050 <adc_set_chan@plt>
mov    $0x0,%al
call   1080 <relay_open@plt>
lea    0xe54(%rip),%rdi
call   1060 <printf@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1040 <show_battery@plt>
mov    $0x0,%al
call   1070 <relay_closed@plt>
lea    0xe3e(%rip),%rdi
call   1060 <printf@plt>
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1040 <show_battery@plt>
mov    $0x0,%al
call   1080 <relay_open@plt>
lea    0xe06(%rip),%rdi
call   1060 <printf@plt>
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1040 <show_battery@plt>
lea    0xdfb(%rip),%rdi
call   1060 <printf@plt>
mov    $0x10,%edi
call   1050 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1090 <show_temp@plt>
lea    0xddd(%rip),%rdi
call   1060 <printf@plt>
mov    $0x11,%edi
call   1050 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   10a0 <show_readings@plt>
lea    0xd87(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1050 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1040 <show_battery@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<adc_test1>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1030 <gpio_a_analog@plt>
lea    0xe82(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1060 <adc_set_chan@plt>
xor    %eax,%eax
call   1080 <relay_open@plt>
lea    0xe4e(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1050 <show_battery@plt>
xor    %eax,%eax
call   1070 <relay_closed@plt>
lea    0xe1c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1050 <show_battery@plt>
xor    %eax,%eax
call   1080 <relay_open@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   10b0 <delay_ms@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1050 <show_battery@plt>
lea    0xde7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x10,%edi
call   1060 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   1090 <show_temp@plt>
lea    0xdc8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x11,%edi
call   1060 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
call   10a0 <show_readings@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1060 <adc_set_chan@plt>
mov    $0x5,%edi
mov    $0x3e8,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <show_battery@plt>

LLVM IR (-O0):
@.str = [16 x i8] c" ADC channel 0\0A\00"
@.str.1 = [12 x i8] c"Relay open\0A\00"
@.str.2 = [14 x i8] c"Relay closed\0A\00"
@.str.3 = [7 x i8] c" temp\0A\00"
@.str.4 = [7 x i8] c" vref\0A\00"
define void @adc_test1() {
%1 = call i32 @gpio_a_analog(i32 0)
%2 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @adc_set_chan(i32 0)
%4 = call i32 (...) @relay_open()
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @show_battery(i32 5, i32 1000)
%7 = call i32 (...) @relay_closed()
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @delay_ms(i32 1000)
%10 = call i32 @show_battery(i32 5, i32 1000)
%11 = call i32 (...) @relay_open()
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @delay_ms(i32 1000)
%14 = call i32 @show_battery(i32 5, i32 1000)
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @adc_set_chan(i32 16)
%17 = call i32 @show_temp(i32 5, i32 1000)
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 @adc_set_chan(i32 17)
%20 = call i32 @show_readings(i32 5, i32 1000)
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @adc_set_chan(i32 0)
%23 = call i32 @show_battery(i32 5, i32 1000)
ret void
}

LLVM IR (-O2):
@str.6 = [13 x i8] c"Relay closed\00"
@str.7 = [11 x i8] c"Relay open\00"
@str.8 = [6 x i8] c" temp\00"
@str.9 = [6 x i8] c" vref\00"
@str.10 = [15 x i8] c" ADC channel 0\00"
define void @adc_test1() {
%1 = tail call i32 @gpio_a_analog(i32 0)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
%3 = tail call i32 @adc_set_chan(i32 0)
%4 = tail call i32 (...) @relay_open()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @show_battery(i32 5, i32 1000)
%7 = tail call i32 (...) @relay_closed()
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @delay_ms(i32 1000)
%10 = tail call i32 @show_battery(i32 5, i32 1000)
%11 = tail call i32 (...) @relay_open()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 @delay_ms(i32 1000)
%14 = tail call i32 @show_battery(i32 5, i32 1000)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%16 = tail call i32 @adc_set_chan(i32 16)
%17 = tail call i32 @show_temp(i32 5, i32 1000)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.9, i64 0, i64 0))
%19 = tail call i32 @adc_set_chan(i32 17)
%20 = tail call i32 @show_readings(i32 5, i32 1000)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.10, i64 0, i64 0))
%22 = tail call i32 @adc_set_chan(i32 0)
%23 = tail call i32 @show_battery(i32 5, i32 1000)
ret void
}