#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 */
scalar_t__ sdb_calloc(int, int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ strstr(char *, char *);
char *avant(char *requete, char *buffer) {
  int j;
  char *res;
  res = (char *)sdb_calloc(100, sizeof(char));
  if (!strstr(requete, buffer)) {
    return (NULL);
  }
  j = strlen(requete) - strlen((char *)strstr(requete, buffer));
  strncpy(res, requete, j);
  res[j] = '\0';
  return res;
}


x86 assembly (clang, -O0):
<avant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   1040 <sdb_calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    1187 <avant+0x47>
movq   $0x0,-0x8(%rbp)
jmp    11d6 <avant+0x96>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<avant>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x64,%edi
mov    $0x1,%esi
call   1040 <sdb_calloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11a5 <avant+0x65>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
jmp    11a8 <avant+0x68>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @avant(i8* %0, i8* %1) {
%3 = tail call i64 @sdb_calloc(i32 100, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i64 @strstr(i8* %0, i8* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = tail call i32 @strlen(i8* %0)
%9 = tail call i64 @strstr(i8* %0, i8* %1)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @strlen(i8* %10)
%12 = sub nsw i32 %8, %11
%13 = tail call i32 @strncpy(i8* %4, i8* %0, i32 %12)
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i8, i8* %4, i64 %14
store i8 0, i8* %15
br label %16
16: ; preds = %2, %7
%17 = phi i8* [ %4, %7 ], [ null, %2 ]
ret i8* %17
}