#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ char2coda(char const);
int smack_coda_string_is_valid(const char *text) {
  assert(text != NULL);
  for (; *text; text++)
    if (*text != '-' && !char2coda(*text))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<smack_coda_string_is_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1192 <smack_coda_string_is_valid+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     117c <smack_coda_string_is_valid+0x5c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <char2coda@plt>
cmp    $0x0,%eax
jne    117c <smack_coda_string_is_valid+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1199 <smack_coda_string_is_valid+0x79>
jmp    1181 <smack_coda_string_is_valid+0x61>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113e <smack_coda_string_is_valid+0x1e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smack_coda_string_is_valid>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
jmp    1144 <smack_coda_string_is_valid+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x2d,%al
je     1140 <smack_coda_string_is_valid+0x20>
test   %al,%al
je     115f <smack_coda_string_is_valid+0x3f>
movsbl %al,%edi
call   1040 <char2coda@plt>
test   %eax,%eax
jne    1140 <smack_coda_string_is_valid+0x20>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @smack_coda_string_is_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
br label %8
8: ; preds = %24, %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 45
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = call i32 @char2coda(i8 signext %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %17
store i32 0, i32* %2
br label %28
23: ; preds = %17, %12
br label %24
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %8
27: ; preds = %8
store i32 1, i32* %2
br label %28
28: ; preds = %27, %22
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @smack_coda_string_is_valid(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
br label %5
5: ; preds = %11, %1
%6 = phi i8* [ %0, %1 ], [ %12, %11 ]
%7 = load i8, i8* %6
switch i8 %7, label %8 [
i8 0, label %13
i8 45, label %11
]
8: ; preds = %5
%9 = tail call i32 @char2coda(i8 signext %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %5, %8
%12 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
13: ; preds = %5, %8
%14 = phi i32 [ 0, %8 ], [ 1, %5 ]
ret i32 %14
}