#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*/ check(int, int, char **);
char *malloc(int);
int /*<<< orphan*/ sscanf(char const *, char *, int *);
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
int main(int argc, char *argv[]) {
  (check((argc == 3), argc, argv));
  const char *literal = argv[1];
  const char *pattern = argv[2];
  int len = strlen(pattern);
  (check((len % 2 == 0), argc, argv));
  char *l2 = malloc(len / 2 + 1);
  int i;
  for (i = 0; i < len; i += 2) {
    int v;
    sscanf(pattern + i, "%2x", &v);
    l2[i / 2] = (char)v;
  }
  l2[len / 2] = '\0';
  (check((strcmp(literal, l2) == 0), argc, argv));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1070 <check@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1070 <check@plt>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1241 <main+0xf1>
mov    -0x20(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
lea    0xdfe(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x38(%rbp),%eax
mov    %al,-0x41(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x41(%rbp),%dl
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    11e4 <main+0x94>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1070 <check@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
xor    %edi,%edi
cmp    $0x3,%r15d
sete   %dil
mov    %r15d,%esi
mov    %r14,%rdx
call   1070 <check@plt>
mov    0x8(%r14),%rax
mov    %rax,0x18(%rsp)
mov    0x10(%r14),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
and    $0x1,%edi
mov    %r15d,(%rsp)
mov    %r15d,%esi
mov    %r14,0x20(%rsp)
mov    %r14,%rdx
call   1070 <check@plt>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    %rax,0x10(%rsp)
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
test   %ebx,%ebx
jle    1207 <main+0xb7>
xor    %r13d,%r13d
lea    0xe2c(%rip),%r14
lea    0x4(%rsp),%r15
mov    0x8(%rsp),%r12
xchg   %ax,%ax
mov    %rbp,%rdi
add    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <sscanf@plt>
movzbl 0x4(%rsp),%eax
mov    %al,(%r12)
add    $0x2,%r13
add    $0x1,%r12
cmp    %r13d,%ebx
jg     11e0 <main+0x90>
movslq 0x10(%rsp),%rax
mov    0x8(%rsp),%rsi
movb   $0x0,(%rsi,%rax,1)
mov    0x18(%rsp),%rdi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
mov    (%rsp),%esi
mov    0x20(%rsp),%rdx
call   1070 <check@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%2x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 3
%14 = zext i1 %13 to i32
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @check(i32 %14, i32 %15, i8** %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = srem i32 %26, 2
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = load i32, i32* %4
%31 = load i8**, i8*** %5
%32 = call i32 @check(i32 %29, i32 %30, i8** %31)
%33 = load i32, i32* %8
%34 = sdiv i32 %33, 2
%35 = add nsw i32 %34, 1
%36 = call i8* @malloc(i32 %35)
store i8* %36, i8** %9
store i32 0, i32* %10
br label %37
37: ; preds = %54, %2
%38 = load i32, i32* %10
%39 = load i32, i32* %8
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %57
41: ; preds = %37
%42 = load i8*, i8** %7
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %11)
%47 = load i32, i32* %11
%48 = trunc i32 %47 to i8
%49 = load i8*, i8** %9
%50 = load i32, i32* %10
%51 = sdiv i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
store i8 %48, i8* %53
br label %54
54: ; preds = %41
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 2
store i32 %56, i32* %10
br label %37
57: ; preds = %37
%58 = load i8*, i8** %9
%59 = load i32, i32* %8
%60 = sdiv i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
store i8 0, i8* %62
%63 = load i8*, i8** %6
%64 = load i8*, i8** %9
%65 = call i64 @strcmp(i8* %63, i8* %64)
%66 = icmp eq i64 %65, 0
%67 = zext i1 %66 to i32
%68 = load i32, i32* %4
%69 = load i8**, i8*** %5
%70 = call i32 @check(i32 %67, i32 %68, i8** %69)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%2x\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 3
%5 = zext i1 %4 to i32
%6 = tail call i32 @check(i32 %5, i32 %0, i8** %1)
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = and i32 %11, 1
%13 = xor i32 %12, 1
%14 = tail call i32 @check(i32 %13, i32 %0, i8** %1)
%15 = sdiv i32 %11, 2
%16 = add nsw i32 %15, 1
%17 = tail call i8* @malloc(i32 %16)
%18 = icmp sgt i32 %11, 0
br i1 %18, label %19, label %32
19: ; preds = %2
%20 = bitcast i32* %3 to i8*
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %29, %21 ]
%23 = getelementptr inbounds i8, i8* %10, i64 %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = trunc i32 %25 to i8
%27 = lshr exact i64 %22, 1
%28 = getelementptr inbounds i8, i8* %17, i64 %27
store i8 %26, i8* %28
%29 = add nuw i64 %22, 2
%30 = trunc i64 %29 to i32
%31 = icmp sgt i32 %11, %30
br i1 %31, label %21, label %32
32: ; preds = %21, %2
%33 = sext i32 %15 to i64
%34 = getelementptr inbounds i8, i8* %17, i64 %33
store i8 0, i8* %34
%35 = call i64 @strcmp(i8* %8, i8* %17)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @check(i32 %37, i32 %0, i8** %1)
ret i32 0
}