#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 */
unsigned int strlen(char const *);
void strtrunc(char *s, const char *delim) {
  unsigned int i, j;
  for (i = 0; i < strlen(s); i++)
    for (j = 0; j < strlen(delim); j++)
      if (s[i] == delim[j]) {
        s[i] = '\0';
        break;
      }
}


x86 assembly (clang, -O0):
<strtrunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jae    11ba <strtrunc+0xaa>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jae    11a7 <strtrunc+0x97>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1194 <strtrunc+0x84>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    11a7 <strtrunc+0x97>
jmp    1199 <strtrunc+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <strtrunc+0x3a>
jmp    11ac <strtrunc+0x9c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <strtrunc+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtrunc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
je     1180 <strtrunc+0x70>
xor    %r15d,%r15d
jmp    1148 <strtrunc+0x38>
nopl   0x0(%rax)
movb   $0x0,(%r14,%r15,1)
add    $0x1,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%r15
jae    1180 <strtrunc+0x70>
mov    %r12,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1135 <strtrunc+0x25>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl (%r14,%r15,1),%eax
cmp    (%r12,%rbx,1),%al
je     1130 <strtrunc+0x20>
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1160 <strtrunc+0x50>
jmp    1135 <strtrunc+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @strtrunc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %7
7: ; preds = %42, %2
%8 = load i32, i32* %5
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = icmp ult i32 %8, %10
br i1 %11, label %12, label %45
12: ; preds = %7
store i32 0, i32* %6
br label %13
13: ; preds = %38, %12
%14 = load i32, i32* %6
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = icmp ult i32 %14, %16
br i1 %17, label %18, label %41
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i8*, i8** %4
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %24, %30
br i1 %31, label %32, label %37
32: ; preds = %18
%33 = load i8*, i8** %3
%34 = load i32, i32* %5
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
br label %41
37: ; preds = %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %6
%40 = add i32 %39, 1
store i32 %40, i32* %6
br label %13
41: ; preds = %32, %13
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add i32 %43, 1
store i32 %44, i32* %5
br label %7
45: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @strtrunc(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %2, %23
%6 = phi i64 [ %24, %23 ], [ 0, %2 ]
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %6
br label %15
11: ; preds = %15
%12 = tail call i32 @strlen(i8* %1)
%13 = zext i32 %12 to i64
%14 = icmp ult i64 %21, %13
br i1 %14, label %15, label %23
15: ; preds = %9, %11
%16 = phi i64 [ 0, %9 ], [ %21, %11 ]
%17 = load i8, i8* %10
%18 = getelementptr inbounds i8, i8* %1, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %17, %19
%21 = add nuw nsw i64 %16, 1
br i1 %20, label %22, label %11
22: ; preds = %15
store i8 0, i8* %10
br label %23
23: ; preds = %11, %5, %22
%24 = add nuw nsw i64 %6, 1
%25 = tail call i32 @strlen(i8* %0)
%26 = zext i32 %25 to i64
%27 = icmp ult i64 %24, %26
br i1 %27, label %5, label %28
28: ; preds = %23, %2
ret void
}