#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__ isdigit(char);
int strlen(char *);
int isNumeric(char *string) {
  int i, n;
  if (string == NULL)
    return -1;
  n = strlen(string);
  for (i = 0; i < n; i++) {
    if (!(isdigit(string[i]) || string[i] == '\n'))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isNumeric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <isNumeric+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b8 <isNumeric+0x98>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b1 <isNumeric+0x91>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    119e <isNumeric+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     119e <isNumeric+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <isNumeric+0x98>
jmp    11a3 <isNumeric+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <isNumeric+0x36>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isNumeric>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1172 <isNumeric+0x52>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1178 <isNumeric+0x58>
mov    %eax,%r15d
xor    %ebp,%ebp
jmp    1159 <isNumeric+0x39>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
cmp    %rbp,%r15
je     1178 <isNumeric+0x58>
movsbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1150 <isNumeric+0x30>
cmpb   $0xa,(%rbx,%rbp,1)
je     1150 <isNumeric+0x30>
xor    %r14d,%r14d
jmp    1178 <isNumeric+0x58>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isNumeric(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %38
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
store i32 0, i32* %4
br label %12
12: ; preds = %34, %9
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %37
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %33, label %32
32: ; preds = %24
store i32 0, i32* %2
br label %38
33: ; preds = %24, %16
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %12
37: ; preds = %12
store i32 1, i32* %2
br label %38
38: ; preds = %37, %32, %8
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
define i32 @isNumeric(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %8
8: ; preds = %6, %17
%9 = phi i64 [ 0, %6 ], [ %18, %17 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8, i8* %10
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %8, %14
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %14, %17, %3, %1
%21 = phi i32 [ -1, %1 ], [ 1, %3 ], [ 0, %14 ], [ 1, %17 ]
ret i32 %21
}