#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 /*<<< orphan*/ printf(char *, ...);
void lookahead(char *str1, int n) {
  char ch1, ch2;
  char ch3[3];
  char *str2;
  str2 = str1 + n;
  ch1 = *str1;
  ch2 = *str2;
  printf("Ch1: %c Ch2: %c \n", ch1, ch2);
  ch3[0] = ch1;
  ch3[1] = ch2;
  ch3[2] = '\0';
  printf("ch3: %s \n", ch3);
}


x86 assembly (clang, -O0):
<lookahead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xd(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xe(%rbp)
movsbl -0xd(%rbp),%esi
movsbl -0xe(%rbp),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xd(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0xe(%rbp),%al
mov    %al,-0x10(%rbp)
movb   $0x0,-0xf(%rbp)
lea    -0x11(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookahead>:
push   %rbp
push   %rbx
push   %rax
movslq %esi,%rax
movsbl (%rdi),%ebx
movsbl (%rdi,%rax,1),%ebp
lea    0xedc(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %bl,0x5(%rsp)
mov    %bpl,0x6(%rsp)
movb   $0x0,0x7(%rsp)
lea    0xece(%rip),%rdi
lea    0x5(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Ch1: %c Ch2: %c \0A\00"
@.str.1 = [10 x i8] c"ch3: %s \0A\00"
define void @lookahead(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca [3 x i8]
%8 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
store i8* %12, i8** %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
store i8 %14, i8* %5
%15 = load i8*, i8** %8
%16 = load i8, i8* %15
store i8 %16, i8* %6
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20)
%22 = load i8, i8* %5
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %22, i8* %23
%24 = load i8, i8* %6
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %24, i8* %25
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 2
store i8 0, i8* %26
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %27)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Ch1: %c Ch2: %c \0A\00"
@.str.1 = [10 x i8] c"ch3: %s \0A\00"
define void @lookahead(i8* nocapture %0, i32 %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %0
%8 = load i8, i8* %6
%9 = sext i8 %7 to i32
%10 = sext i8 %8 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
store i8 %7, i8* %4
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 %8, i8* %12
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 2
store i8 0, i8* %13
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}