#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 strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int podstring(char *s1, char *s2) {
  int i;
  int d1 = strlen(s1);
  int d2 = strlen(s2);
  if (d1 > d2)
    return 0;
  for (i = 0; i <= d2 - d1; i++)
    if (strncmp(s1, s2 + i, d1) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<podstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    1160 <podstring+0x40>
movl   $0x0,-0x4(%rbp)
jmp    11bf <podstring+0x9f>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jg     11b8 <podstring+0x98>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11a5 <podstring+0x85>
movl   $0x1,-0x4(%rbp)
jmp    11bf <podstring+0x9f>
jmp    11aa <podstring+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <podstring+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<podstring>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
xor    %r15d,%r15d
sub    %r12d,%ebp
jl     1175 <podstring+0x55>
add    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     116f <podstring+0x4f>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1150 <podstring+0x30>
jmp    1175 <podstring+0x55>
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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