#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, int *, char *);
int /*<<< orphan*/ stderr;
int pl_IChar(void *variable, int argc, char *argv[], int i, int k) {
  int int_variable;
  char c = '\0';
  if (i >= argc) {
    fprintf(stderr, "The command line is missing an integer at its end.\n\n");
    return (0);
  } else if ((sscanf(&argv[i][k], "%d%c", &int_variable, &c) != 1) ||
             (c != '\0')) {
    fprintf(stderr, "\"%s\" (from item %d on the command line) ", &argv[i][k],
            i);
    fprintf(stderr, "is not an integer.\n\n");
    return (0);
  } else {
    *(char *)variable = (char)int_variable;
    return (i + 1);
  }
}


x86 assembly (clang, -O0):
<pl_IChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
movb   $0x0,-0x2d(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     116d <pl_IChar+0x4d>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <pl_IChar+0xee>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
lea    0xeae(%rip),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x2d(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11aa <pl_IChar+0x8a>
movsbl -0x2d(%rbp),%eax
cmp    $0x0,%eax
je     11fa <pl_IChar+0xda>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x28(%rbp),%rax
add    %rax,%rdx
mov    -0x24(%rbp),%ecx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <pl_IChar+0xee>
mov    -0x2c(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pl_IChar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xb(%rsp)
cmp    %esi,%ecx
jge    117b <pl_IChar+0x5b>
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rdi,%r12
movslq %ecx,%rbp
movslq %r8d,%r15
mov    (%rdx,%rbp,8),%rdi
add    %r15,%rdi
lea    0xee4(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0xb(%rsp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    118f <pl_IChar+0x6f>
cmpb   $0x0,0xb(%rsp)
jne    118f <pl_IChar+0x6f>
mov    0xc(%rsp),%al
mov    %al,(%r12)
add    $0x1,%ebx
mov    %ebx,%ebp
jmp    11c5 <pl_IChar+0xa5>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
xor    %ebp,%ebp
jmp    11be <pl_IChar+0x9e>
mov    0x2e4a(%rip),%r12
mov    (%r12),%edi
add    (%r14,%rbp,8),%r15
lea    0xe95(%rip),%rsi
xor    %ebp,%ebp
mov    %r15,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r12),%edi
lea    0xea5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [53 x i8] c"The command line is missing an integer at its end.\0A\0A\00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [41 x i8] c"\22%s\22 (from item %d on the command line) \00"
@.str.3 = [21 x i8] c"is not an integer.\0A\0A\00"
define i32 @pl_IChar(i8* %0, i32 %1, i8** %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8 0, i8* %13
%14 = load i32, i32* %10
%15 = load i32, i32* %8
%16 = icmp sge i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %5
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %55
20: ; preds = %5
%21 = load i8**, i8*** %9
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %12, i8* %13)
%30 = icmp ne i32 %29, 1
br i1 %30, label %35, label %31
31: ; preds = %20
%32 = load i8, i8* %13
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %31, %20
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %9
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i32, i32* %10
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %44, i32 %45)
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %55
49: ; preds = %31
%50 = load i32, i32* %12
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %7
store i8 %51, i8* %52
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %55
55: ; preds = %49, %35, %17
%56 = load i32, i32* %6
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [53 x i8] c"The command line is missing an integer at its end.\0A\0A\00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [41 x i8] c"\22%s\22 (from item %d on the command line) \00"
@.str.3 = [21 x i8] c"is not an integer.\0A\0A\00"
define i32 @pl_IChar(i8* nocapture writeonly %0, i32 %1, i8** nocapture %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8
%8 = bitcast i32* %6 to i8*
store i8 0, i8* %7
%9 = icmp slt i32 %3, %1
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %35
13: ; preds = %5
%14 = sext i32 %3 to i64
%15 = getelementptr inbounds i8*, i8** %2, i64 %14
%16 = load i8*, i8** %15
%17 = sext i32 %4 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i8* %7)
%20 = icmp ne i32 %19, 1
%21 = load i8, i8* %7
%22 = icmp ne i8 %21, 0
%23 = select i1 %20, i1 true, i1 %22
br i1 %23, label %24, label %31
24: ; preds = %13
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %15
%27 = getelementptr inbounds i8, i8* %26, i64 %17
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %27, i32 %3)
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %35
31: ; preds = %13
%32 = load i32, i32* %6
%33 = trunc i32 %32 to i8
store i8 %33, i8* %0
%34 = add nsw i32 %3, 1
br label %35
35: ; preds = %31, %24, %10
%36 = phi i32 [ 0, %10 ], [ 0, %24 ], [ %34, %31 ]
ret i32 %36
}