#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*/ LOG_ERR;
scalar_t__ isdigit(char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int check_input(char *input) {
  int i;
  for (i = 0; i < 4; i++) {
    if (isdigit(input[i]) == 0) {
      syslog(LOG_ERR, "Invalid input.");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    118c <check_input+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    1179 <check_input+0x59>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <check_input+0x73>
jmp    117e <check_input+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1133 <check_input+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_input>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1162 <check_input+0x42>
movsbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1162 <check_input+0x42>
movsbl 0x2(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1162 <check_input+0x42>
movsbl 0x3(%rbx),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1162 <check_input+0x42>
pop    %rbx
ret
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1040 <syslog@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LOG_ERR = global i32 0
@.str = [15 x i8] c"Invalid input.\00"
define i32 @check_input(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 4
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i32, i32* @LOG_ERR
%18 = call i32 @syslog(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %24
19: ; preds = %8
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %5
store i32 0, i32* %2
br label %24
24: ; preds = %23, %16
%25 = load i32, i32* %2
ret i32 %25
}

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