#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__ ft_isdigit(char);
int /*<<< orphan*/ ft_putendl(char *);
int check_direct(char *param) {
  if (ft_isdigit(*param) || *param == '-') {
    param++;
    while (*param) {
      if (!ft_isdigit(*param++))
        ft_putendl("Invalid direct number.");
    }
  }
  return (2);
}


x86 assembly (clang, -O0):
<check_direct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <ft_isdigit@plt>
cmp    $0x0,%rax
jne    1152 <check_direct+0x32>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11a2 <check_direct+0x82>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     119d <check_direct+0x7d>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1040 <ft_isdigit@plt>
cmp    $0x0,%rax
jne    1198 <check_direct+0x78>
lea    0xe6d(%rip),%rdi
call   1030 <ft_putendl@plt>
jmp    115e <check_direct+0x3e>
jmp    11a2 <check_direct+0x82>
mov    $0x2,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_direct>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1040 <ft_isdigit@plt>
test   %rax,%rax
jne    1139 <check_direct+0x19>
cmpb   $0x2d,(%rbx)
jne    1172 <check_direct+0x52>
mov    0x1(%rbx),%al
test   %al,%al
je     1172 <check_direct+0x52>
add    $0x2,%rbx
lea    0xeb5(%rip),%r14
jmp    115b <check_direct+0x3b>
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1172 <check_direct+0x52>
movsbl %al,%edi
call   1040 <ft_isdigit@plt>
test   %rax,%rax
jne    1150 <check_direct+0x30>
mov    %r14,%rdi
call   1030 <ft_putendl@plt>
jmp    1150 <check_direct+0x30>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Invalid direct number.\00"
define i32 @check_direct(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = call i64 @ft_isdigit(i8 signext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 45
br i1 %11, label %12, label %29
12: ; preds = %7, %1
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %2
br label %15
15: ; preds = %27, %12
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
%22 = load i8, i8* %20
%23 = call i64 @ft_isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %19
%26 = call i32 @ft_putendl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28, %7
ret i32 2
}

LLVM IR (-O2):
@.str = [23 x i8] c"Invalid direct number.\00"
define i32 @check_direct(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @ft_isdigit(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 45
br i1 %7, label %8, label %23
8: ; preds = %5, %1
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %8, %19
%13 = phi i8 [ %21, %19 ], [ %10, %8 ]
%14 = phi i8* [ %20, %19 ], [ %9, %8 ]
%15 = tail call i64 @ft_isdigit(i8 signext %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @ft_putendl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = getelementptr inbounds i8, i8* %14, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %12
23: ; preds = %19, %8, %5
ret i32 2
}