#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 __get_array_size(char *);
int __infer_nondet_int();
char *fgets(char *str, int num, FILE *stream) {
  int n;
  int size1;
  FILE tmp;
  tmp = *stream;
  n = __infer_nondet_int();
  if (n > 0) {
    size1 = __get_array_size(str);
    if (num > size1)
      while (1)
        ;
    return str;
  } else
    return NULL;
}


x86 assembly (clang, -O0):
<fgets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1030 <__infer_nondet_int@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    117f <fgets+0x5f>
mov    -0x10(%rbp),%rdi
call   1040 <__get_array_size@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1172 <fgets+0x52>
jmp    116d <fgets+0x4d>
jmp    116d <fgets+0x4d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1187 <fgets+0x67>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgets>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <__infer_nondet_int@plt>
test   %eax,%eax
jle    1142 <fgets+0x22>
mov    %rbx,%rdi
call   1040 <__get_array_size@plt>
cmp    %ebp,%eax
jge    1144 <fgets+0x24>
nop
jmp    1140 <fgets+0x20>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @fgets(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%11 = load i32*, i32** %7
%12 = load i32, i32* %11
store i32 %12, i32* %10
%13 = call i32 (...) @__infer_nondet_int()
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = call i32 @__get_array_size(i8* %17)
store i32 %18, i32* %9
%19 = load i32, i32* %6
%20 = load i32, i32* %9
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %16
br label %23
23: ; preds = %22, %23
br label %23
24: ; preds = %16
%25 = load i8*, i8** %5
store i8* %25, i8** %4
br label %27
26: ; preds = %3
store i8* null, i8** %4
br label %27
27: ; preds = %26, %24
%28 = load i8*, i8** %4
ret i8* %28
}

LLVM IR (-O2):
define i8* @fgets(i8* %0, i32 %1, i32* nocapture readnone %2) {
%4 = tail call i32 (...) @__infer_nondet_int()
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32 @__get_array_size(i8* %0)
%8 = icmp slt i32 %7, %1
br i1 %8, label %9, label %10
9: ; preds = %6, %9
br label %9
10: ; preds = %3, %6
%11 = phi i8* [ %0, %6 ], [ null, %3 ]
ret i8* %11
}