#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int /*<<< orphan*/);
int parse_i2c_slave_address(char *s) {
  char *endptr;
  long n = strtol(s, &endptr, 0);
  if (endptr == s || *endptr != 0) {
    fprintf(stderr, "bad slave address '%s'\n", s);
    exit(1);
  }
  if (n < 0x3 || n > 0x77) {
    fprintf(stderr, "slave address %ld outside legal range\n", n);
    exit(1);
  }
  return n;
}


x86 assembly (clang, -O0):
<parse_i2c_slave_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     116d <parse_i2c_slave_address+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1192 <parse_i2c_slave_address+0x62>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpq   $0x3,-0x18(%rbp)
jl     11a8 <parse_i2c_slave_address+0x78>
cmpq   $0x77,-0x18(%rbp)
jle    11cd <parse_i2c_slave_address+0x9d>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_i2c_slave_address>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    0x8(%rsp),%rcx
cmp    %rbx,%rcx
je     1166 <parse_i2c_slave_address+0x36>
cmpb   $0x0,(%rcx)
jne    1166 <parse_i2c_slave_address+0x36>
mov    %rax,%rcx
add    $0xffffffffffffff88,%rcx
cmp    $0xffffffffffffff8a,%rcx
jbe    117b <parse_i2c_slave_address+0x4b>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdx
jmp    118e <parse_i2c_slave_address+0x5e>
mov    0x2e5e(%rip),%rcx
mov    (%rcx),%edi
lea    0xe8d(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"bad slave address '%s'\0A\00"
@.str.1 = [39 x i8] c"slave address %ld outside legal range\0A\00"
define i32 @parse_i2c_slave_address(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strtol(i8* %5, i8** %3, i32 0)
store i64 %6, i64* %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %2
%9 = icmp eq i8* %7, %8
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10, %1
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %10
%21 = load i64, i64* %4
%22 = icmp slt i64 %21, 3
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i64, i64* %4
%25 = icmp sgt i64 %24, 119
br i1 %25, label %26, label %31
26: ; preds = %23, %20
%27 = load i32, i32* @stderr
%28 = load i64, i64* %4
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %23
%32 = load i64, i64* %4
%33 = trunc i64 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"bad slave address '%s'\0A\00"
@.str.1 = [39 x i8] c"slave address %ld outside legal range\0A\00"
define i32 @parse_i2c_slave_address(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @strtol(i8* %0, i8** %2, i32 0)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, %0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7, %1
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = add i64 %4, -120
%16 = icmp ult i64 %15, -117
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 %4)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %14
%22 = trunc i64 %4 to i32
ret i32 %22
}