#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 first_instance(char *, char *);
int /*<<< orphan*/ getString(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setString(char *, int);
void main() {
  char a[80], b[80];
  printf("enter a string A (< 80 chars): ");
  setString(a, 80);
  printf("enter a string B (< 80 chars): ");
  setString(b, 80);
  printf("String A: ");
  getString(a);
  printf("\nString B: ");
  getString(b);
  (first_instance(a, b) != -1)
      ? printf("\nstring B offset %d chars from beginning of A",
               first_instance(a, b))
      : printf("\nString B can not be found in string A");
  return;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x50,%esi
call   1060 <setString@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x50,%esi
call   1060 <setString@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
call   1030 <getString@plt>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1030 <getString@plt>
lea    -0x50(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <first_instance@plt>
cmp    $0xffffffff,%eax
je     11f5 <main+0xb5>
lea    -0x50(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <first_instance@plt>
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1203 <main+0xc3>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x50,%esi
call   1060 <setString@plt>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <setString@plt>
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <getString@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <getString@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <first_instance@plt>
cmp    $0xffffffff,%eax
je     11e3 <main+0xa3>
lea    0x50(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <first_instance@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f1 <main+0xb1>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [32 x i8] c"enter a string A (< 80 chars): \00"
@.str.1 = [32 x i8] c"enter a string B (< 80 chars): \00"
@.str.2 = [11 x i8] c"String A: \00"
@.str.3 = [12 x i8] c"\0AString B: \00"
@.str.4 = [46 x i8] c"\0Astring B offset %d chars from beginning of A\00"
@.str.5 = [39 x i8] c"\0AString B can not be found in string A\00"
define void @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = call i32 @setString(i8* %4, i32 80)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = call i32 @setString(i8* %7, i32 80)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%11 = call i32 @getString(i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%14 = call i32 @getString(i8* %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%17 = call i32 @first_instance(i8* %15, i8* %16)
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %0
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%22 = call i32 @first_instance(i8* %20, i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %26
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = phi i32 [ %23, %19 ], [ %25, %24 ]
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"enter a string A (< 80 chars): \00"
@.str.1 = [32 x i8] c"enter a string B (< 80 chars): \00"
@.str.2 = [11 x i8] c"String A: \00"
@.str.3 = [12 x i8] c"\0AString B: \00"
@.str.4 = [46 x i8] c"\0Astring B offset %d chars from beginning of A\00"
@.str.5 = [39 x i8] c"\0AString B can not be found in string A\00"
define void @main() {
%1 = alloca [80 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @setString(i8* %3, i32 80)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @setString(i8* %4, i32 80)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @getString(i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @getString(i8* %4)
%13 = call i32 @first_instance(i8* %3, i8* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = call i32 @first_instance(i8* %3, i8* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %20
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret void
}