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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *parse(char const *, int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ reg_write(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void setup(const char *init) {
  uint8_t p0, p0mdout, p2, p2mdout;
  init = parse(init, &p0, &p0mdout, 8);
  init = parse(init, &p2, &p2mdout, 6);
  if (*init) {
    fprintf(stderr, "too many pin settings\n");
    exit(1);
  }
  reg_write(0x80, p0);
  reg_write(0xa4, p0mdout);
  reg_write(0xa0, p2);
  reg_write(0xa6, p2mdout);
}


x86 assembly (clang, -O0):
<setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x8,%ecx
call   1040 <parse@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x6,%ecx
call   1040 <parse@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ac <setup+0x6c>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%esi
mov    $0x80,%edi
call   1050 <reg_write@plt>
mov    -0x10(%rbp),%esi
mov    $0xa4,%edi
call   1050 <reg_write@plt>
mov    -0x14(%rbp),%esi
mov    $0xa0,%edi
call   1050 <reg_write@plt>
mov    -0x18(%rbp),%esi
mov    $0xa6,%edi
call   1050 <reg_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup>:
sub    $0x18,%rsp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    $0x8,%ecx
call   1040 <parse@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
mov    $0x6,%ecx
call   1040 <parse@plt>
cmpb   $0x0,(%rax)
jne    11b1 <setup+0x71>
mov    0x14(%rsp),%esi
mov    $0x80,%edi
call   1050 <reg_write@plt>
mov    0x10(%rsp),%esi
mov    $0xa4,%edi
call   1050 <reg_write@plt>
mov    0xc(%rsp),%esi
mov    $0xa0,%edi
call   1050 <reg_write@plt>
mov    0x8(%rsp),%esi
mov    $0xa6,%edi
call   1050 <reg_write@plt>
add    $0x18,%rsp
ret
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"too many pin settings\0A\00"
define void @setup(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @parse(i8* %7, i32* %3, i32* %4, i32 8)
store i8* %8, i8** %2
%9 = load i8*, i8** %2
%10 = call i8* @parse(i8* %9, i32* %5, i32* %6, i32 6)
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = load i32, i32* %3
%20 = call i32 @reg_write(i32 128, i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @reg_write(i32 164, i32 %21)
%23 = load i32, i32* %5
%24 = call i32 @reg_write(i32 160, i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @reg_write(i32 166, i32 %25)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"too many pin settings\0A\00"
define void @setup(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i8* @parse(i8* %0, i32* %2, i32* %3, i32 8)
%11 = call i8* @parse(i8* %10, i32* %4, i32* %5, i32 6)
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = load i32, i32* %2
%20 = call i32 @reg_write(i32 128, i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @reg_write(i32 164, i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @reg_write(i32 160, i32 %23)
%25 = load i32, i32* %5
%26 = call i32 @reg_write(i32 166, i32 %25)
ret void
}