#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*/ ciao_atom(char *);
int /*<<< orphan*/ ciao_raise_exception(int /*<<< orphan*/);
int /*<<< orphan*/ ciao_structure(char *, int, int /*<<< orphan*/);
int strtol(char *, char **, int);
int codes_to_number_c(char *s) {
  char *endptr;
  int n;
  n = strtol(s, &endptr, 10);
  if (endptr == NULL || *endptr != '\0') {
    ciao_raise_exception(
        ciao_structure("codes_to_number_exception", 1, ciao_atom(s)));
  }
  return n;
}


x86 assembly (clang, -O0):
<codes_to_number_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <codes_to_number_c+0x3c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119f <codes_to_number_c+0x5f>
mov    -0x8(%rbp),%rdi
call   1060 <ciao_atom@plt>
mov    %eax,%edx
lea    0xe72(%rip),%rdi
mov    $0x1,%esi
call   1030 <ciao_structure@plt>
mov    %eax,%edi
call   1040 <ciao_raise_exception@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<codes_to_number_c>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
test   %rax,%rax
je     1163 <codes_to_number_c+0x23>
cmpb   $0x0,(%rax)
je     1185 <codes_to_number_c+0x45>
mov    %rbx,%rdi
call   1060 <ciao_atom@plt>
lea    0xe8e(%rip),%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <ciao_structure@plt>
mov    %eax,%edi
call   1040 <ciao_raise_exception@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"codes_to_number_exception\00"
define i32 @codes_to_number_c(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strtol(i8* %5, i8** %3, i32 10)
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9, %1
%15 = load i8*, i8** %2
%16 = call i32 @ciao_atom(i8* %15)
%17 = call i32 @ciao_structure(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32 %16)
%18 = call i32 @ciao_raise_exception(i32 %17)
br label %19
19: ; preds = %14, %9
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
@.str = [26 x i8] c"codes_to_number_exception\00"
define i32 @codes_to_number_c(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i32 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
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 = tail call i32 @ciao_atom(i8* %0)
%12 = tail call i32 @ciao_structure(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32 %11)
%13 = tail call i32 @ciao_raise_exception(i32 %12)
br label %14
14: ; preds = %10, %7
ret i32 %4
}