#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ execute_token(char *);
int /*<<< orphan*/ free(char *);
int fscanf(int /*<<< orphan*/ *, char *, char **);
void execute_stream(FILE *stream) {
  char *token;
  int nr_matches;
  for (nr_matches = fscanf(stream, "%ms ", &token); nr_matches == 1;
       nr_matches = fscanf(stream, "%ms ", &token)) {
    execute_token(token);
    free(token);
  }
}


x86 assembly (clang, -O0):
<execute_stream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    118b <execute_stream+0x5b>
mov    -0x10(%rbp),%rdi
call   1050 <execute_token@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x14(%rbp)
jmp    1153 <execute_stream+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_stream>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xebd(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1187 <execute_stream+0x57>
lea    0xea7(%rip),%r14
lea    0x8(%rsp),%r15
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
call   1050 <execute_token@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     1160 <execute_stream+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ms \00"
define void @execute_stream(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3)
store i32 %6, i32* %4
br label %7
7: ; preds = %15, %1
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = call i32 @execute_token(i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %10
%16 = load i32*, i32** %2
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3)
store i32 %17, i32* %4
br label %7
18: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ms \00"
define void @execute_stream(i32* nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %13
6: ; preds = %1, %6
%7 = load i8*, i8** %2
%8 = call i32 @execute_token(i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @free(i8* %9)
%11 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2)
%12 = icmp eq i32 %11, 1
br i1 %12, label %6, label %13
13: ; preds = %6, %1
ret void
}