#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 */
size_t strlen(char *);
int consists_entirely_of(char *string, char value) {
  for (size_t i = 0; i < strlen(string); i++) {
    if (string[i] != value) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<consists_entirely_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    1185 <consists_entirely_of+0x75>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
je     116f <consists_entirely_of+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    118c <consists_entirely_of+0x7c>
jmp    1174 <consists_entirely_of+0x64>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112a <consists_entirely_of+0x1a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consists_entirely_of>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %rax,%rax
je     114c <consists_entirely_of+0x3c>
xor    %ecx,%ecx
cmp    %bpl,(%rbx)
jne    1151 <consists_entirely_of+0x41>
mov    $0x1,%ecx
xchg   %ax,%ax
mov    %rcx,%rdx
cmp    %rcx,%rax
je     1142 <consists_entirely_of+0x32>
lea    0x1(%rdx),%rcx
cmp    %bpl,(%rbx,%rdx,1)
je     1130 <consists_entirely_of+0x20>
xor    %ecx,%ecx
cmp    %rax,%rdx
setae  %cl
jmp    1151 <consists_entirely_of+0x41>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @consists_entirely_of(i8* nocapture %0, i8 signext %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, %1
br i1 %7, label %8, label %19
8: ; preds = %5, %11
%9 = phi i64 [ %15, %11 ], [ 1, %5 ]
%10 = icmp eq i64 %9, %3
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %0, i64 %9
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, %1
%15 = add nuw i64 %9, 1
br i1 %14, label %8, label %16
16: ; preds = %8, %11
%17 = icmp uge i64 %9, %3
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %16, %5, %2
%20 = phi i32 [ 1, %2 ], [ 0, %5 ], [ %18, %16 ]
ret i32 %20
}