#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);
int is_valid_const(char const *);
scalar_t__ strlen(char const *);
int btor_is_zero_const(const char *str) {
  const char *p;
  assert(str != NULL);
  assert((int)strlen(str) > 0);
  assert(is_valid_const(str));
  for (p = str; *p; p++)
    if (*p != '0')
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<btor_is_zero_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <is_valid_const@plt>
mov    %eax,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11be <btor_is_zero_const+0x8e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
je     11a8 <btor_is_zero_const+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <btor_is_zero_const+0x95>
jmp    11ad <btor_is_zero_const+0x7d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117f <btor_is_zero_const+0x4f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btor_is_zero_const>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <is_valid_const@plt>
mov    %eax,%edi
call   1050 <assert@plt>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%eax
cmp    $0x30,%al
jne    117d <btor_is_zero_const+0x4d>
add    $0x1,%rbx
jmp    1170 <btor_is_zero_const+0x40>
test   %al,%al
jne    1188 <btor_is_zero_const+0x58>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @btor_is_zero_const(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
%12 = icmp sgt i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %3
%16 = call i32 @is_valid_const(i8* %15)
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %3
store i8* %18, i8** %4
br label %19
19: ; preds = %30, %1
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 48
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 0, i32* %2
br label %34
29: ; preds = %23
br label %30
30: ; preds = %29
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %19
33: ; preds = %19
store i32 1, i32* %2
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @btor_is_zero_const(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = trunc i64 %5 to i32
%7 = icmp sgt i32 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @is_valid_const(i8* %0)
%11 = tail call i32 @assert(i32 %10)
br label %12
12: ; preds = %15, %1
%13 = phi i8* [ %0, %1 ], [ %16, %15 ]
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 0, label %18
i8 48, label %15
]
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %12
17: ; preds = %12
br label %18
18: ; preds = %12, %17
%19 = phi i32 [ 0, %17 ], [ 1, %12 ]
ret i32 %19
}