#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 */
scalar_t__ errno;
int /*<<< orphan*/ error_print(char *, char *);
int strtoul(char *, char **, int /*<<< orphan*/);
int check_no_cyl(char *no_cyl) {
  int nr_cyl;
  char *err_ptr;
  if (!no_cyl) {
    return 2;
  } else {
    err_ptr = NULL;
    nr_cyl = strtoul(no_cyl, &err_ptr, 0);
    if ((errno) || (*err_ptr != '\0')) {
      error_print("Invalid number of cylinders given '%s'", no_cyl);
      return -1;
    }
  }
  return nr_cyl;
}


x86 assembly (clang, -O0):
<check_no_cyl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <check_no_cyl+0x23>
movl   $0x2,-0x4(%rbp)
jmp    11a5 <check_no_cyl+0x85>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e7c(%rip),%rax
cmpq   $0x0,(%rax)
jne    117e <check_no_cyl+0x5e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119a <check_no_cyl+0x7a>
mov    -0x10(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1030 <error_print@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <check_no_cyl+0x85>
jmp    119f <check_no_cyl+0x7f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_no_cyl>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     116f <check_no_cyl+0x4f>
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x2e97(%rip),%rcx
cmpq   $0x0,(%rcx)
jne    1159 <check_no_cyl+0x39>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     1174 <check_no_cyl+0x54>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <error_print@plt>
mov    $0xffffffff,%eax
jmp    1174 <check_no_cyl+0x54>
mov    $0x2,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [39 x i8] c"Invalid number of cylinders given '%s'\00"
define i32 @check_no_cyl(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 2, i32* %2
br label %25
9: ; preds = %1
store i8* null, i8** %5
%10 = load i8*, i8** %3
%11 = call i32 @strtoul(i8* %10, i8** %5, i32 0)
store i32 %11, i32* %4
%12 = load i64, i64* @errno
%13 = icmp ne i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14, %9
%20 = load i8*, i8** %3
%21 = call i32 @error_print(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %2
br label %25
22: ; preds = %14
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %25
25: ; preds = %23, %19, %8
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [39 x i8] c"Invalid number of cylinders given '%s'\00"
define i32 @check_no_cyl(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %15, label %5
5: ; preds = %1
store i8* null, i8** %2
%6 = call i32 @strtoul(i8* %0, i8** %2, i32 0)
%7 = load i64, i64* @errno
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9, %5
%14 = tail call i32 @error_print(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %9, %1, %13
%16 = phi i32 [ -1, %13 ], [ 2, %1 ], [ %6, %9 ]
ret i32 %16
}