#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 const);
int payment_validate_ccnum(const char *str, int *pos, void *arg) {
  const char *s;
  for (s = str; *s; *s++)
    if (!(isdigit(*s) || *s == ' ')) {
      *pos = s - str;
      return -1;
    }
  return 0;
}


x86 assembly (clang, -O0):
<payment_validate_ccnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1194 <payment_validate_ccnum+0x84>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    117e <payment_validate_ccnum+0x6e>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     117e <payment_validate_ccnum+0x6e>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <payment_validate_ccnum+0x8b>
jmp    1183 <payment_validate_ccnum+0x73>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    112c <payment_validate_ccnum+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<payment_validate_ccnum>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     115c <payment_validate_ccnum+0x4c>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    113e <payment_validate_ccnum+0x2e>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     115c <payment_validate_ccnum+0x4c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <payment_validate_ccnum+0x20>
cmpb   $0x20,(%r15,%rbx,1)
je     1130 <payment_validate_ccnum+0x20>
mov    %ebx,(%r14)
mov    $0xffffffff,%eax
jmp    115e <payment_validate_ccnum+0x4e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @payment_validate_ccnum(i8* %0, i32* nocapture writeonly %1, i8* nocapture readnone %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %3, %19
%7 = phi i8 [ %21, %19 ], [ %4, %3 ]
%8 = phi i8* [ %20, %19 ], [ %0, %3 ]
%9 = tail call i64 @isdigit(i8 signext %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 32
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = ptrtoint i8* %8 to i64
%16 = ptrtoint i8* %0 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
store i32 %18, i32* %1
br label %23
19: ; preds = %6, %11
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %23, label %6
23: ; preds = %19, %3, %14
%24 = phi i32 [ -1, %14 ], [ 0, %3 ], [ 0, %19 ]
ret i32 %24
}